Jelajahi Sumber

feat(mac-ops): Add quickrun.sh consolidator

quickrun.sh   Sequences the 5 highest-yield audits and emits a single
              CONSOLIDATED VERDICT block:
                1. health-audit (8-rung orchestrator)
                2. startup-audit (login items + launchd)
                3. storage-pressure (snapshots + caches)
                4. wake-reasons (7-day pmset analysis)
                5. tcc-audit --denied (privacy denials)

              Aggregates pass/fail/warn counts across all sub-scripts.
              Collects FAIL and WARN lines into a top-10 bulleted finding
              list. Useful for the "60 seconds, what's broken?" workflow
              rather than running 22 individual scripts.

Time: 60-90s typical (log show queries dominate).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0xDarkMatter 2 bulan lalu
induk
melakukan
16abb50cf1
4 mengubah file dengan 142 tambahan dan 2 penghapusan
  1. 1 1
      .claude-plugin/plugin.json
  2. 3 0
      README.md
  3. 137 0
      skills/mac-ops/scripts/quickrun.sh
  4. 1 1
      skills/mac-ops/tests/run.sh

+ 1 - 1
.claude-plugin/plugin.json

@@ -1,6 +1,6 @@
 {
   "name": "claude-mods",
-  "version": "2.7.6",
+  "version": "2.7.7",
   "description": "Custom commands, skills, and agents for Claude Code - session continuity, 23 expert agents, 78 skills, 2 commands, 6 rules, 4 hooks, 13 output styles, modern CLI tools",
   "author": "0xDarkMatter",
   "repository": "https://github.com/0xDarkMatter/claude-mods",

+ 3 - 0
README.md

@@ -22,6 +22,9 @@ From Python async patterns to Rust ownership models, from AWS Fargate deployment
 
 ## Recent Updates
 
+**v2.7.7** (May 2026)
+- ๐Ÿฉบ **`mac-ops` quickrun consolidator** - Added `quickrun.sh` โ€” one-shot "what's wrong with my Mac?" runner that sequences the 5 highest-yield audits (health-audit + startup-audit + storage-pressure + wake-reasons + tcc-audit --denied) and emits a single CONSOLIDATED VERDICT with aggregate PASS/FAIL/WARN counts plus the top failures and warnings as bulleted findings. Designed for the "60 seconds, what's broken?" workflow vs running 22 individual scripts. Total: 23 scripts, 11 reference docs, 6,780+ lines.
+
 **v2.7.6** (May 2026)
 - ๐Ÿฉบ **`mac-ops` worked examples** - Added `worked-examples.md` reference with three end-to-end diagnostic walkthroughs: "Mac is slow and hot" (Spotlight reindex + Power Nap wake pattern), "Can't share screen on Zoom" (TCC denial after macOS update โ€” the canonical case for `tccutil reset ScreenCapture`), and "Disk full but I deleted everything" (APFS local snapshots + cache directories). Each walkthrough shows the symptom, the script sequence, the actual signal in output, and the fix command. Useful as recognition patterns for the most common modern Mac complaints. Total: 22 scripts, 11 reference docs, 6,564 lines.
 

+ 137 - 0
skills/mac-ops/scripts/quickrun.sh

@@ -0,0 +1,137 @@
+#!/usr/bin/env bash
+# mac-ops :: quickrun.sh
+# One-shot "what's wrong with my Mac?" runner. Sequences the 5 highest-yield
+# audits and emits a single consolidated report.
+#
+# This is the script to run if you have 60 seconds and want to know whether
+# something needs attention. For deep dives, drill into individual scripts.
+
+set -u
+
+SHORT_DAYS=7
+while [[ $# -gt 0 ]]; do
+    case "$1" in
+        --days) SHORT_DAYS="$2"; shift 2 ;;
+        --help|-h)
+            cat <<EOF
+Usage: $0 [options]
+
+  --days N           Lookback for log-based audits (default: 7)
+  --json             Emit consolidated NDJSON
+  --redact           Mask private addrs / hostnames / serials
+
+Runs (in order):
+  1. health-audit         โ€” orchestrator across 8 rungs
+  2. startup-audit        โ€” login items + launchd inventory
+  3. storage-pressure     โ€” APFS snapshots + caches breakdown
+  4. wake-reasons         โ€” pmset log analysis (last week)
+  5. tcc-audit (denied)   โ€” what privacy permissions were denied
+
+Output: one consolidated SUMMARY at end with all PASS/FAIL counts and the
+top 3 issues to address.
+
+Time: 60-90 seconds typical (log show queries dominate).
+EOF
+            exit 0 ;;
+        *) shift ;;
+    esac
+done
+
+source "$(dirname "$0")/_lib/common.sh"
+parse_common_flags "$@"
+maybe_filter_self "$@"
+
+SCRIPTS_DIR="$(dirname "$0")"
+
+# Aggregate counters across all sub-scripts
+TOTAL_PASS=0
+TOTAL_FAIL=0
+TOTAL_WARN=0
+TOTAL_INFO=0
+ALL_FAILS=()
+ALL_WARNS=()
+
+run_subscript() {
+    local label="$1"
+    local script="$2"
+    shift 2
+    note ""
+    note "โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"
+    note "  $label"
+    note "โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"
+
+    # Capture sub-script output (suppress its own SUMMARY since we'll do our own)
+    local out
+    out=$(bash "$SCRIPTS_DIR/$script" --quiet "$@" 2>&1 || true)
+
+    # Echo the sub-script's findings (everything before its SUMMARY)
+    echo "$out" | sed -n '/^=== /,/^=== SUMMARY ===/p' | sed '/^=== SUMMARY ===/q' | sed '$d'
+
+    # Extract sub-script's pass/fail/warn counts from its SUMMARY line
+    local summary_line
+    summary_line=$(echo "$out" | grep -E "^  PASS: [0-9]+" | head -1)
+    if [[ -n "$summary_line" ]]; then
+        local pass fail warn info
+        pass=$(echo "$summary_line" | grep -oE "PASS: [0-9]+" | awk '{print $2}')
+        fail=$(echo "$summary_line" | grep -oE "FAIL: [0-9]+" | awk '{print $2}')
+        warn=$(echo "$summary_line" | grep -oE "WARN: [0-9]+" | awk '{print $2}')
+        info=$(echo "$summary_line" | grep -oE "INFO: [0-9]+" | awk '{print $2}')
+        TOTAL_PASS=$((TOTAL_PASS + ${pass:-0}))
+        TOTAL_FAIL=$((TOTAL_FAIL + ${fail:-0}))
+        TOTAL_WARN=$((TOTAL_WARN + ${warn:-0}))
+        TOTAL_INFO=$((TOTAL_INFO + ${info:-0}))
+    fi
+
+    # Collect FAIL and WARN lines for the consolidated summary
+    while IFS= read -r line; do
+        [[ -n "$line" ]] && ALL_FAILS+=("[$label] $line")
+    done < <(echo "$out" | grep -E "^\[FAIL\]" | sed 's/^\[FAIL\] //')
+    while IFS= read -r line; do
+        [[ -n "$line" ]] && ALL_WARNS+=("[$label] $line")
+    done < <(echo "$out" | grep -E "^\[WARN\]" | sed 's/^\[WARN\] //')
+}
+
+note "  Starting mac-ops quickrun (this takes ~60-90s due to log show queries)..."
+
+run_subscript "1. HEALTH AUDIT" "health-audit.sh" --days "$SHORT_DAYS"
+run_subscript "2. STARTUP INVENTORY" "startup-audit.sh"
+run_subscript "3. STORAGE PRESSURE" "storage-pressure.sh"
+run_subscript "4. WAKE REASONS (last ${SHORT_DAYS}d)" "wake-reasons.sh" --since "${SHORT_DAYS}d"
+run_subscript "5. TCC DENIALS" "tcc-audit.sh" --denied
+
+# ----------------------------------------------------------------------------
+note ""
+note "โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"
+note "  CONSOLIDATED VERDICT"
+note "โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•"
+
+if [[ "$JSON_MODE" -eq 1 ]]; then
+    printf '{"type":"quickrun_summary","pass":%d,"fail":%d,"warn":%d,"info":%d,"fail_count":%d,"warn_count":%d}\n' \
+        "$TOTAL_PASS" "$TOTAL_FAIL" "$TOTAL_WARN" "$TOTAL_INFO" \
+        "${#ALL_FAILS[@]}" "${#ALL_WARNS[@]}"
+else
+    echo
+    echo "  Aggregate: PASS $TOTAL_PASS    FAIL $TOTAL_FAIL    WARN $TOTAL_WARN    INFO $TOTAL_INFO"
+    echo
+    if [[ "${#ALL_FAILS[@]}" -gt 0 ]]; then
+        echo "  โš  FAILURES (${#ALL_FAILS[@]}):"
+        for f in ${ALL_FAILS[@]+"${ALL_FAILS[@]}"}; do
+            echo "    โ€ข $f"
+        done | head -10
+    fi
+    if [[ "${#ALL_WARNS[@]}" -gt 0 ]]; then
+        echo
+        echo "  โš  WARNINGS (${#ALL_WARNS[@]}):"
+        for w in ${ALL_WARNS[@]+"${ALL_WARNS[@]}"}; do
+            echo "    โ€ข $w"
+        done | head -10
+    fi
+    if [[ "${#ALL_FAILS[@]}" -eq 0 ]] && [[ "${#ALL_WARNS[@]}" -eq 0 ]]; then
+        echo "  โœ“ System looks clean. No FAILs or WARNs across 5 audits."
+    fi
+    echo
+    echo "  Next steps:"
+    echo "    - Drill into any FAIL: see 'Next:' lines emitted by each sub-script"
+    echo "    - Run individual scripts with --verbose for more detail"
+    echo "    - See references/worked-examples.md for diagnostic patterns"
+fi

+ 1 - 1
skills/mac-ops/tests/run.sh

@@ -175,7 +175,7 @@ expected_scripts=(
     tcc-audit.sh wake-reasons.sh spotlight-status.sh storage-pressure.sh
     kext-audit.sh firewall-audit.sh network-locations.sh
     sysdiagnose-helper.sh brew-health.sh update-state.sh media-libraries.sh
-    keychain-audit.sh bluetooth-audit.sh font-audit.sh
+    keychain-audit.sh bluetooth-audit.sh font-audit.sh quickrun.sh
 )
 for s in "${expected_scripts[@]}"; do
     assert "script exists: $s" test -f "$root/scripts/$s"