mirror of
https://github.com/MaksTinyWorkshop/_Assistant_Lead_Tech
synced 2026-04-06 21:41:42 +02:00
Affiner sync projets + publication skills Claude/Codex
This commit is contained in:
@@ -137,12 +137,124 @@ infer_scope() {
|
||||
esac
|
||||
}
|
||||
|
||||
infer_state() {
|
||||
local root="$1"
|
||||
local sprint_status_file="$root/_bmad-output/implementation-artifacts/sprint-status.yaml"
|
||||
local stories_dir="$root/_bmad-output/implementation-artifacts/stories"
|
||||
local first_story
|
||||
local latest_story
|
||||
local epic_num
|
||||
|
||||
if [ -f "$sprint_status_file" ]; then
|
||||
local in_dev="false"
|
||||
local line trimmed key val story_epic
|
||||
local active_epic="" active_ts="-1"
|
||||
local prep_epic=""
|
||||
local declared_in_progress_epic=""
|
||||
local story_file story_ts
|
||||
local -a matches=()
|
||||
|
||||
while IFS= read -r line || [ -n "$line" ]; do
|
||||
if [ "$line" = "development_status:" ]; then
|
||||
in_dev="true"
|
||||
continue
|
||||
fi
|
||||
|
||||
if [ "$in_dev" = "true" ] && [ -n "$(trim "$line")" ] && [[ ! "$line" =~ ^[[:space:]] ]]; then
|
||||
in_dev="false"
|
||||
fi
|
||||
[ "$in_dev" = "true" ] || continue
|
||||
|
||||
trimmed="$(trim "$line")"
|
||||
[[ "$trimmed" == *:* ]] || continue
|
||||
key="$(trim "${trimmed%%:*}")"
|
||||
val="$(trim "${trimmed#*:}")"
|
||||
|
||||
if [[ "$key" =~ ^epic-([0-9]+)$ ]]; then
|
||||
story_epic="${BASH_REMATCH[1]}"
|
||||
if [ "$val" = "in-progress" ]; then
|
||||
if [ -z "$declared_in_progress_epic" ] || [ "$story_epic" -lt "$declared_in_progress_epic" ]; then
|
||||
declared_in_progress_epic="$story_epic"
|
||||
fi
|
||||
fi
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ "$key" =~ ^([0-9]+)-[0-9]+[a-z]?-.*$ ]]; then
|
||||
story_epic="${BASH_REMATCH[1]}"
|
||||
if [ "$val" = "in-progress" ] || [ "$val" = "review" ]; then
|
||||
matches=()
|
||||
shopt -s nullglob
|
||||
matches=( "$stories_dir/epic-$story_epic/${key}"*.md )
|
||||
shopt -u nullglob
|
||||
story_ts="0"
|
||||
if [ ${#matches[@]} -gt 0 ]; then
|
||||
story_file="${matches[0]}"
|
||||
story_ts="$(stat -c %Y "$story_file" 2>/dev/null || printf '0')"
|
||||
fi
|
||||
if [ "$story_ts" -gt "$active_ts" ] || { [ "$story_ts" -eq "$active_ts" ] && { [ -z "$active_epic" ] || [ "$story_epic" -gt "$active_epic" ]; }; }; then
|
||||
active_ts="$story_ts"
|
||||
active_epic="$story_epic"
|
||||
fi
|
||||
elif [ "$val" = "ready-for-dev" ] || [ "$val" = "backlog" ]; then
|
||||
if [ -z "$prep_epic" ] || [ "$story_epic" -lt "$prep_epic" ]; then
|
||||
prep_epic="$story_epic"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
done < "$sprint_status_file"
|
||||
|
||||
if [ -n "$active_epic" ]; then
|
||||
printf 'Epic %s en cours' "$active_epic"
|
||||
return
|
||||
fi
|
||||
if [ -n "$prep_epic" ]; then
|
||||
printf 'Epic %s en préparation' "$prep_epic"
|
||||
return
|
||||
fi
|
||||
if [ -n "$declared_in_progress_epic" ]; then
|
||||
printf 'Epic %s en préparation' "$declared_in_progress_epic"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -d "$stories_dir" ]; then
|
||||
first_story="$(find "$stories_dir" -maxdepth 2 -type f -name '*.md' \
|
||||
! -name 'epic-*-retro*.md' -print -quit 2>/dev/null)"
|
||||
if [ -n "$first_story" ]; then
|
||||
latest_story="$(find "$stories_dir" -maxdepth 2 -type f -name '*.md' \
|
||||
! -name 'epic-*-retro*.md' -print 2>/dev/null \
|
||||
| xargs ls -1t 2>/dev/null \
|
||||
| head -n 1)"
|
||||
if [ -n "$latest_story" ]; then
|
||||
epic_num="$(echo "$latest_story" | sed -n 's#.*\/epic-\([0-9][0-9]*\)\/.*#\1#p')"
|
||||
if [ -n "$epic_num" ]; then
|
||||
printf 'Epic %s en préparation' "$epic_num"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
printf '%s' "dev"
|
||||
}
|
||||
|
||||
is_progress_state() {
|
||||
local state="$1"
|
||||
[ -z "$state" ] && return 0
|
||||
case "$state" in
|
||||
dev|active) return 0 ;;
|
||||
esac
|
||||
echo "$state" | grep -Eq '^Epic [0-9]+ en (préparation|cours)$'
|
||||
}
|
||||
|
||||
PROJECT_NAME="${PROJECT_NAME:-$(basename "$PROJECT_ROOT")}"
|
||||
STACK_INFERRED="$(infer_stack "$PROJECT_ROOT")"
|
||||
SCOPE_INFERRED="$(infer_scope "$PROJECT_ROOT")"
|
||||
STATE_INFERRED="$(infer_state "$PROJECT_ROOT")"
|
||||
STACK="${STACK_OVERRIDE:-$STACK_INFERRED}"
|
||||
SCOPE="${SCOPE_OVERRIDE:-$SCOPE_INFERRED}"
|
||||
STATE="${STATE_OVERRIDE:-dev}"
|
||||
STATE="${STATE_OVERRIDE:-$STATE_INFERRED}"
|
||||
|
||||
if ! [[ "$SCOPE" =~ ^(perso|mindleaf|lab|archive)$ ]]; then
|
||||
echo "Erreur: scope invalide '$SCOPE' (attendu: perso|mindleaf|lab|archive)" >&2
|
||||
@@ -183,6 +295,8 @@ EOF
|
||||
|
||||
if [ -n "$STATE_OVERRIDE" ]; then
|
||||
TARGET_STATE="$STATE_OVERRIDE"
|
||||
elif is_progress_state "$existing_state"; then
|
||||
TARGET_STATE="$STATE_INFERRED"
|
||||
else
|
||||
TARGET_STATE="$existing_state"
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user