From dc5356b242bd8fbcdbf0003edf9f3dfd0af673d7 Mon Sep 17 00:00:00 2001 From: Levi Neely Date: Sun, 19 Apr 2026 11:14:36 +0200 Subject: [PATCH] tools: walk up from CWD to find .beads for monorepo support The .beads check now traverses parent directories so plan_* enforcement works from any subdirectory of the repo, not just the root. Co-Authored-By: Claude Sonnet 4.6 --- tools/plan_check | 9 ++++++++- tools/plan_create | 3 ++- tools/plan_finish | 9 ++++++++- tools/plan_start | 3 ++- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/tools/plan_check b/tools/plan_check index 1597a80..124cdf0 100755 --- a/tools/plan_check +++ b/tools/plan_check @@ -8,7 +8,14 @@ if len(sys.argv) < 3: sys.exit(1) import shutil -if os.environ.get('OLLIE_BEADS_ENABLE', '1') != '0' and shutil.which('bd') and os.path.exists('.beads'): +def _find_beads(): + d = os.getcwd() + while d != os.path.dirname(d): + if os.path.isdir(os.path.join(d, '.beads')): + return True + d = os.path.dirname(d) + return False +if os.environ.get('OLLIE_BEADS_ENABLE', '1') != '0' and shutil.which('bd') and _find_beads(): print("error: beads is available — use 'bd' for planning instead of plan_check", file=sys.stderr) sys.exit(2) diff --git a/tools/plan_create b/tools/plan_create index 7dd5266..03ae2a6 100755 --- a/tools/plan_create +++ b/tools/plan_create @@ -4,7 +4,8 @@ # Output: plan filename in pl/ set -euo pipefail -if [ "${OLLIE_BEADS_ENABLE:-1}" != "0" ] && command -v bd >/dev/null 2>&1 && [ -d ".beads" ]; then +_find_beads() { local d="$PWD"; while [ "$d" != "/" ]; do [ -d "$d/.beads" ] && return 0; d="$(dirname "$d")"; done; return 1; } +if [ "${OLLIE_BEADS_ENABLE:-1}" != "0" ] && command -v bd >/dev/null 2>&1 && _find_beads; then echo "error: beads is available — use 'bd' for planning instead of plan_create" >&2 exit 2 fi diff --git a/tools/plan_finish b/tools/plan_finish index b4a5cd4..0affd3c 100755 --- a/tools/plan_finish +++ b/tools/plan_finish @@ -9,7 +9,14 @@ if len(sys.argv) < 2: sys.exit(1) import shutil -if os.environ.get('OLLIE_BEADS_ENABLE', '1') != '0' and shutil.which('bd') and os.path.exists('.beads'): +def _find_beads(): + d = os.getcwd() + while d != os.path.dirname(d): + if os.path.isdir(os.path.join(d, '.beads')): + return True + d = os.path.dirname(d) + return False +if os.environ.get('OLLIE_BEADS_ENABLE', '1') != '0' and shutil.which('bd') and _find_beads(): print("error: beads is available — use 'bd' for planning instead of plan_finish", file=sys.stderr) sys.exit(2) diff --git a/tools/plan_start b/tools/plan_start index 5c96ea6..b3934b7 100755 --- a/tools/plan_start +++ b/tools/plan_start @@ -4,7 +4,8 @@ # Output: new filename set -euo pipefail -if [ "${OLLIE_BEADS_ENABLE:-1}" != "0" ] && command -v bd >/dev/null 2>&1 && [ -d ".beads" ]; then +_find_beads() { local d="$PWD"; while [ "$d" != "/" ]; do [ -d "$d/.beads" ] && return 0; d="$(dirname "$d")"; done; return 1; } +if [ "${OLLIE_BEADS_ENABLE:-1}" != "0" ] && command -v bd >/dev/null 2>&1 && _find_beads; then echo "error: beads is available — use 'bd' for planning instead of plan_start" >&2 exit 2 fi