Loading...
Loading...
Migrate phase directories to globally sequential numbering, fixing duplicate numeric prefixes across milestones. Triggers include "migrate phases", "fix phase numbers", "renumber phases", "phase collision", "fix phase collisions", "fix duplicate phases", "phase numbering migration".
npx skill4agent add gannonh/kata-skills kata-migrate-phases01-foundation01-setupcompleted/find ... -name "01-*" | head -1DUPES=$(for state in active pending completed; do
ls .planning/phases/${state}/ 2>/dev/null
done | grep -oE '^[0-9]+' | sort -n | uniq -d)
# Also check flat directories (unmigrated projects)
FLAT_DUPES=$(ls .planning/phases/ 2>/dev/null | grep -E '^[0-9]' | grep -oE '^[0-9]+' | sort -n | uniq -d)
ALL_DUPES=$(echo -e "${DUPES}\n${FLAT_DUPES}" | sort -nu | grep -v '^$')
echo "Duplicate prefixes: ${ALL_DUPES:-none}"No phase prefix collisions detected. All phase directories have unique numeric prefixes.[ -f .planning/ROADMAP.md ] || { echo "ERROR: No ROADMAP.md found. Not a Kata project."; exit 1; }
[ -f .planning/STATE.md ] || { echo "ERROR: No STATE.md found. Not a Kata project."; exit 1; }━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Kata ► PHASE MIGRATION
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
◆ Duplicate prefixes detected: [list]
◆ Building chronology from ROADMAP.md...<details>#### Phase N:{global_seq} {phase_name}phase_nameGLOBAL_SEQ=0
CHRONOLOGY=""
# Parse all "Phase N: name" lines from ROADMAP.md in document order.
# Completed milestones appear in <details> blocks; current milestone uses #### headings.
# Both formats contain "Phase N: name" — grep catches all.
while IFS= read -r line; do
name=$(echo "$line" | grep -oE 'Phase [0-9.]+: .+' | sed 's/Phase [0-9.]*: //' | sed 's/\*\*$//' | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -cd 'a-z0-9-')
if [ -n "$name" ]; then
CHRONOLOGY="${CHRONOLOGY}${GLOBAL_SEQ} ${name}\n"
GLOBAL_SEQ=$((GLOBAL_SEQ + 1))
fi
done < <(grep -E 'Phase [0-9.]+:' .planning/ROADMAP.md)Chronology ([N] phases): 00 → foundation, 01 → api-endpoints, ...active/pending/completed/{seq} {name}{name}STATE/OLD_DIR → STATE/NEW_PREFIX-SLUGMAPPINGSTATE/OLD_DIR → PADDED-SLUGMigration Plan:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
completed/01-foundation → completed/00-foundation
completed/02-api-endpoints → completed/01-api-endpoints
completed/01-setup → completed/02-setup
...
active/01-current-work → active/15-current-work
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Total: [N] directories to renamekata-move-phasemv OLD tmp-{seq}-{slug}mv tmp-{seq}-{slug} {padded}-{slug}*-PLAN.md*-RESEARCH.md*-CONTEXT.md*-SUMMARY.mdsed "s/^[0-9.]*-/${PADDED}-/"*-PLAN.md◆ Pass 1: Renamed [N] directories to temporary names
◆ Pass 2: Renamed [N] directories to final names
◆ Active/pending internal files updated: [count]#### Phase N:<details>.planning/milestones/◆ Updated ROADMAP.md current milestone phase numbers
◆ Updated STATE.md current positionDUPES=$(for state in active pending completed; do
ls .planning/phases/${state}/ 2>/dev/null
done | grep -oE '^[0-9]+' | sort -n | uniq -d)
FLAT_DUPES=$(ls .planning/phases/ 2>/dev/null | grep -E '^[0-9]' | grep -oE '^[0-9]+' | sort -n | uniq -d)
ALL_DUPES=$(echo -e "${DUPES}\n${FLAT_DUPES}" | sort -nu | grep -v '^$')━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Kata ► MIGRATION COMPLETE
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
✓ [N] directories renamed to globally sequential numbers
✓ No duplicate prefixes remain
✓ ROADMAP.md and STATE.md updatedCOMMIT_PLANNING_DOCS=$(cat .planning/config.json 2>/dev/null | grep -o '"commit_docs"[[:space:]]*:[[:space:]]*[^,}]*' | grep -o 'true\|false' || echo "true")
git check-ignore -q .planning 2>/dev/null && COMMIT_PLANNING_DOCS=falseCOMMIT_PLANNING_DOCS=falseCOMMIT_PLANNING_DOCS=truegit add .planning/phases/ .planning/ROADMAP.md .planning/STATE.md
git commit -m "$(cat <<'EOF'
chore: migrate phase directories to globally sequential numbering
EOF
)"<details><details>