#!/usr/bin/env bash # Commit all working-tree changes with a conventional message. # # Intended for AI work sessions so that every session leaves a trace in git. # It stages everything, runs the safety checks, then commits. It does not push; # use scripts/publish.sh for that. # # Usage: scripts/agent-commit.sh "" # # Environment: # PHOEBUS_COMMIT_TEST=0 skip the fast test run before committing set -euo pipefail message="${1:-}" if [[ -z "$message" ]]; then echo "usage: scripts/agent-commit.sh \"\"" >&2 exit 2 fi root="$(git rev-parse --show-toplevel)" cd "$root" if [[ -z "$(git status --porcelain)" ]]; then echo "nothing to commit (working tree clean)" exit 0 fi git add -A scripts/check-secrets.sh if [[ "${PHOEBUS_COMMIT_TEST:-1}" == "1" ]] && command -v cargo >/dev/null 2>&1; then echo "running Rust test suite..." (cd installer-rs && cargo test --workspace) >/tmp/phoebus-agent-commit-tests.log 2>&1 || { echo "tests failed; see /tmp/phoebus-agent-commit-tests.log" >&2 exit 1 } fi echo "staged changes:" git diff --cached --stat | tail -n 40 # The checks above already ran; skip the hook's duplicate work. SKIP_PHOEBUS_HOOKS=1 git commit -m "$message" echo echo "committed: $(git log -1 --oneline)" echo "push with: scripts/publish.sh"