Add --pick flag to gsd-tools.cjs for extracting a single field from JSON output, replacing all jq pipe usage across workflow and reference files. Since Node.js is already a hard dependency, this eliminates the need for jq on systems where it is not installed (notably Windows). Changes: - gsd-tools.cjs: add --pick <field> global flag with dot-notation and bracket syntax support (e.g., --pick section, --pick directories[-1]) - Replace 15 jq pipe patterns across 6 workflow/reference files with --pick flag or inline Node.js one-liner for variable extraction - Add regression tests for --pick flag behavior Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1.5 KiB
1.5 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=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" find-phase "${PHASE}")
Returns JSON with:
found: true/falsedirectory: Full path to phase directoryphase_number: Normalized number (e.g., "06", "06.1")phase_name: Name portion (e.g., "foundation")plans: Array of PLAN.md filessummaries: 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=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" 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=$(node "$HOME/.claude/get-shit-done/bin/gsd-tools.cjs" find-phase "${PHASE}" --raw)