aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/status.sh77
1 files changed, 77 insertions, 0 deletions
diff --git a/scripts/status.sh b/scripts/status.sh
new file mode 100755
index 0000000..0dd23f5
--- /dev/null
+++ b/scripts/status.sh
@@ -0,0 +1,77 @@
+#!/usr/bin/env bash
+#
+# status.sh — compact summary of repo health and inflight work.
+#
+# Composes existing checks (audit, doctor, todo count, inbox count, git
+# status). No new logic beyond formatting. Target output is ~10 lines,
+# scannable in one glance.
+
+set -uo pipefail
+
+repo_root="$(git rev-parse --show-toplevel 2>/dev/null)" || {
+ echo "status: not inside a git checkout" >&2
+ exit 2
+}
+cd "$repo_root"
+
+echo "rulesets status — $(date '+%Y-%m-%d %H:%M %Z')"
+
+# audit + doctor: audit.sh runs doctor internally; one call gives both.
+audit_summary="$(bash scripts/audit.sh 2>&1 | grep '^Summary:' | tail -1)"
+echo " audit ${audit_summary:-(no summary)}"
+
+# Sync-check: canonical/mirror parity.
+if bash scripts/sync-check.sh >/dev/null 2>&1; then
+ echo " sync canonical = mirror"
+else
+ echo " sync DRIFT (run make sync-check FIX=1)"
+fi
+
+# Open task count: top-level TODO/DOING entries in the Open Work section
+# of todo.org (skip DONE and CANCELLED; skip the Resolved section).
+if [ -f todo.org ]; then
+ open_count=$(awk '
+ /^\* .* Open Work/ { in_open=1; next }
+ /^\* / { in_open=0 }
+ in_open && /^\*\* (TODO|DOING|VERIFY) / { n++ }
+ END { print n+0 }
+ ' todo.org)
+ echo " todo $open_count open"
+else
+ echo " todo (no todo.org)"
+fi
+
+# Inbox count: files excluding .gitkeep and PROCESSED- prefixes.
+if [ -d inbox ]; then
+ inbox_count=$(find inbox -maxdepth 1 -type f \
+ ! -name '.gitkeep' \
+ ! -name 'PROCESSED-*' \
+ 2>/dev/null | wc -l)
+ echo " inbox $inbox_count unprocessed"
+else
+ echo " inbox (no inbox/)"
+fi
+
+# Git state: dirty/clean + ahead/behind.
+branch=$(git symbolic-ref --short HEAD 2>/dev/null || echo "(detached)")
+if [ -z "$(git status --porcelain 2>/dev/null)" ]; then
+ tree_state="clean"
+else
+ tree_state="dirty"
+fi
+upstream_state=""
+if upstream=$(git rev-parse --abbrev-ref "${branch}@{upstream}" 2>/dev/null); then
+ counts=$(git rev-list --left-right --count "${upstream}...${branch}" 2>/dev/null) || counts="? ?"
+ behind=$(echo "$counts" | cut -f1)
+ ahead=$(echo "$counts" | cut -f2)
+ if [ "$behind" = "0" ] && [ "$ahead" = "0" ]; then
+ upstream_state=" — in sync with $upstream"
+ elif [ "$behind" = "0" ]; then
+ upstream_state=" — $ahead ahead of $upstream"
+ elif [ "$ahead" = "0" ]; then
+ upstream_state=" — $behind behind $upstream"
+ else
+ upstream_state=" — diverged ($ahead ahead, $behind behind) from $upstream"
+ fi
+fi
+echo " git $branch $tree_state$upstream_state"