* fix(#4830): re-land #4768's letter-suffix phase-id fix and its lint-phase-id-drift ratchets on current next Commit740ba0d8a(#4781) removed every change #4768 had merged for #4748: the first-non-digit split at execute-phase.md's two arithmetic sites, the init-emitted `padded_phase` the REVIEW.md lookup binds instead of `printf "%02d"`, the canonical-grammar extractions in autonomous.md and plan-review-convergence.md, the `.changeset/zesty-wolves-tumble.md` fragment, and the three lint-phase-id-drift ratchets with their tests. The guard and the code it guarded left together, so nothing went red. This is a cherry-pick of092d9256bonto current `next`, resolved against the #4683 threat-id fields on execute-phase.md's Parse-JSON line, with the changeset `pr:` reset to the placeholder and the compact-content benchmark baseline regenerated against the current base. (cherry picked from commit092d9256b8) Emitted-Drift-Ack-Growth: autonomous.md — restores #4768's canonical-grammar extraction and its explanatory comment for --from/--to/--only Emitted-Drift-Ack-Growth: execute-phase.md — restores #4768's first-non-digit split at two arithmetic sites and the padded_phase binding for the REVIEW.md lookup Emitted-Drift-Ack-Growth: plan-review-convergence.md — restores #4768's canonical-grammar phase extraction and its comment Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AX7LXxc3uAkGki6iaYiAMP * chore(#4830): set changeset fragment pr to 4873 --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> Co-authored-by: Tom Boucher <trekkie@nomorestars.com>
64 lines
1.7 KiB
Markdown
64 lines
1.7 KiB
Markdown
# 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:
|
|
|
|
```bash
|
|
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 the leading integer to 2 digits. Preserve a letter suffix and any dotted
|
|
segments — the canonical grammar in `src/phase-id.cts` (`normalizePhaseName`):
|
|
`8 → 08`, `2.1 → 02.1`, `3A → 03A`, `23.1.2 → 23.1.2`.
|
|
|
|
```bash
|
|
# Normalize phase number
|
|
# #4748: one branch for the whole canonical token — digits, optional [A-Z],
|
|
# dotted segments. Pad through $((10#…)) so an already-padded `08` is not read
|
|
# as octal by printf; anything non-canonical passes through untouched.
|
|
if [[ "$PHASE" =~ ^([0-9]+)([A-Z]?)((\.[0-9]+)*)$ ]]; then
|
|
PHASE_INT=${BASH_REMATCH[1]}
|
|
PHASE=$(printf "%02d" "$((10#$PHASE_INT))")${BASH_REMATCH[2]}${BASH_REMATCH[3]}
|
|
fi
|
|
```
|
|
|
|
## Validation
|
|
|
|
Use `roadmap get-phase` to validate phase exists:
|
|
|
|
```bash
|
|
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:
|
|
|
|
```bash
|
|
PHASE_DIR=$(gsd_run query find-phase "${PHASE}" --raw)
|
|
```
|