feat(crunch): add script mode for custom pipeline jobs

crunch script <type> <time> <script.sh> [args...]

Runs any shell script on schedule. Script stdout is piped to talk
for voice output. Empty stdout = silence (no error thrown).

Enables complex multi-step pipelines:
  - Fetch data (basecamp, gh, curl)
  - Write reports to disk
  - Pipe through pi/opencode for AI summarization
  - Final stdout → talk voice notification

Example:
  crunch script daily '08:00' ~/scripts/basecamp-daily.sh
This commit is contained in:
2026-07-02 19:55:31 +02:00
parent 9e96e92cfe
commit 8b3d762bc9
+25
View File
@@ -32,6 +32,7 @@
crunch daily <time> <message> Recurring daily at time
crunch weekly <day> <time> <message> Recurring weekly (Mon or Montag)
crunch ai <engine> <type> <time> <prompt> AI crunch (pi|opencode)
crunch script <type> <time> <script.sh> [args] Custom script talk
crunch list List active jobs
crunch cancel <name> Cancel a job
crunch purge Remove fired one-shot jobs
@@ -45,6 +46,7 @@
crunch weekly "Montag 09:00" "Weekly review"
crunch ai pi in "1h" "Fasse neueste Commits zusammen"
crunch ai opencode daily "08:00" "Review offene Issues"
crunch script daily "08:00" ~/scripts/basecamp-daily.sh
crunch list
crunch cancel mll-rausbringen-12345
@@ -146,6 +148,15 @@
esac
exit $?
;;
_script)
script_path="$2"; shift 2
rc=0
output=$(bash "$script_path" "$@" 2>&1) || rc=$?
if [ -n "''${output:-}" ]; then
printf '%s' "$output" | "$TALK"
fi
exit "$rc"
;;
esac
# CLI
@@ -198,6 +209,20 @@
"$SELF _ai $engine $(printf '%q' "$prompt")" "$name"
;;
# Custom script crunch jobs
script)
[ $# -lt 3 ] && { echo "Usage: crunch script <at|in|daily|weekly> <time> <script.sh> [args...]" >&2; exit 1; }
sub_type="$1"; time_spec="$2"; script_path="$3"; shift 3
script_path="$(readlink -f "$script_path")"
[ ! -f "$script_path" ] && { echo "Script not found: $script_path" >&2; exit 1; }
name="$(make_name "$(basename "$script_path" .sh)")"
exec_cmd="$SELF _script $(printf '%q' "$script_path")"
if [ $# -gt 0 ]; then
exec_cmd+=" $(printf '%q ' "$@")"
fi
schedule "$sub_type" "$time_spec" "$exec_cmd" "$name"
;;
# Management
list)
echo "Active crunch jobs:"