47 lines
1.2 KiB
Bash
Executable File
47 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# phase-status.sh — phase pipeline state for the Phase Architect.
|
|
#
|
|
# Finds the project root (nearest ancestor with .agent/phases/todo), prints
|
|
# the todo/ and complete/ phase listings, and computes the next free phase
|
|
# number NN (counting both directories together, zero-padded to 2 digits).
|
|
#
|
|
# Usage: bash phase-status.sh # from anywhere in the project tree
|
|
|
|
set -euo pipefail
|
|
|
|
root="$(pwd)"
|
|
while :; do
|
|
if [[ -d "$root/.agent/phases/todo" ]]; then break; fi
|
|
[[ "$root" == "/" ]] && { echo "✗ ERROR: no .agent/phases/todo found at or above $(pwd)" >&2; exit 1; }
|
|
root="$(dirname "$root")"
|
|
done
|
|
|
|
list() {
|
|
local d="$root/.agent/phases/$1" f found=0
|
|
for f in "$d"/*.md; do
|
|
[[ -e "$f" ]] || continue
|
|
found=1
|
|
printf ' %s\n' "$(basename "$f")"
|
|
done
|
|
if (( ! found )); then printf ' (empty)\n'; fi
|
|
}
|
|
|
|
max=0
|
|
for d in todo complete; do
|
|
for f in "$root/.agent/phases/$d"/*.md; do
|
|
[[ -e "$f" ]] || continue
|
|
n="$(basename "$f" .md)"
|
|
if [[ "$n" =~ ^([0-9]+) ]]; then
|
|
n=$((10#${BASH_REMATCH[1]}))
|
|
if (( n > max )); then max=$n; fi
|
|
fi
|
|
done
|
|
done
|
|
|
|
echo "project root: $root"
|
|
echo "todo:"
|
|
list todo
|
|
echo "complete:"
|
|
list complete
|
|
echo "next number: $(printf '%02d' $((max + 1)))"
|