Files
msd-core/gsd-core/references/phase-argument-parsing.md
Tom Boucher 740ba0d8a3 fix(#4628): expose DAG-ready plans and restrict dispatch to them (#4781)
Emitted-Drift-Ack-Growth: execute-phase.md — #4628 consumer wiring: ready_plans parse pointer, not-ready named skip, and waiting condition 2b reference to the ready-wave-gate step file

Co-authored-by: sim <sim@local>
2026-09-16 02:38:43 -04:00

1.4 KiB

Phase Argument Parsing

Parse and normalize phase arguments for commands that operate on phases.

Extraction

From $ARGUMENTS:

  • Extract phase number (first numeric argument)
  • Extract flags (prefixed with --)
  • Remaining text is description (for insert/add commands)

Using gsd-tools

The find-phase command handles normalization and validation in one step:

PHASE_INFO=$(gsd_run query find-phase "${PHASE}")

Returns JSON with:

  • found: true/false
  • directory: Full path to phase directory
  • phase_number: Normalized number (e.g., "06", "06.1")
  • phase_name: Name portion (e.g., "foundation")
  • plans: Array of PLAN.md files
  • summaries: Array of SUMMARY.md files

Manual Normalization (Legacy)

Zero-pad integer phases to 2 digits. Preserve decimal suffixes.

# Normalize phase number
if [[ "$PHASE" =~ ^[0-9]+$ ]]; then
  # Integer: 8 → 08
  PHASE=$(printf "%02d" "$PHASE")
elif [[ "$PHASE" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
  # Decimal: 2.1 → 02.1
  PHASE=$(printf "%02d.%s" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
fi

Validation

Use roadmap get-phase to validate phase exists:

PHASE_CHECK=$(gsd_run query roadmap.get-phase "${PHASE}" --pick found)
if [ "$PHASE_CHECK" = "false" ]; then
  echo "ERROR: Phase ${PHASE} not found in roadmap"
  exit 1
fi

Directory Lookup

Use find-phase for directory lookup:

PHASE_DIR=$(gsd_run query find-phase "${PHASE}" --raw)