Files
msd-core/docs/zh-CN/references/phase-argument-parsing.md
Jakub Zych a9a7a328e6 refactor: hard-fork GSD -> MSD (Make Software Done)
Mechanical rename produced by scripts/msd-rename.cjs: gsd/Gsd/GSD -> msd/Msd/MSD
across contents and paths, upstream package/repo coordinates -> @golem15/msd-core
and golem15com/msd-core. Deep links into upstream history, sibling upstream
packages, the GSD-2 import feature, CHANGELOG.md and .changeset/ are kept as-is.

Hand edits on top: MSD block-letter banner and logos, LICENSE copyright line,
package/plugin identity, regenerated lockfile, install-tree fixtures, derived
registries and benchmark baseline; migration checksum baseline re-locked
(MSD keeps its own install state, so no install had applied the old sums);
sort-order and regex-escaped expectations in tests adjusted.
2026-10-06 01:47:40 +02:00

61 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# 阶段参数解析
为操作阶段的命令解析和规范化阶段参数。
## 提取
从 `$ARGUMENTS` 中:
- 提取阶段编号(第一个数字参数)
- 提取标志(以 `--` 为前缀)
- 剩余文本为描述(用于 insert/add 命令)
## 使用 msd-tools
`find-phase` 命令一步完成规范化和验证:
```bash
PHASE_INFO=$(node "$HOME/.claude/msd-core/bin/msd-tools.cjs" find-phase "${PHASE}")
```
返回 JSON 包含:
- `found`: true/false
- `directory`: 阶段目录的完整路径
- `phase_number`: 规范化的编号(如 "06"、"06.1")
- `phase_name`: 名称部分(如 "foundation")
- `plans`: PLAN.md 文件数组
- `summaries`: SUMMARY.md 文件数组
## 手动规范化(遗留)
将整数阶段补零到 2 位。保留小数后缀。
```bash
# 规范化阶段编号
if [[ "$PHASE" =~ ^[0-9]+$ ]]; then
# 整数: 8 → 08
PHASE=$(printf "%02d" "$PHASE")
elif [[ "$PHASE" =~ ^([0-9]+)\.([0-9]+)$ ]]; then
# 小数: 2.1 → 02.1
PHASE=$(printf "%02d.%s" "${BASH_REMATCH[1]}" "${BASH_REMATCH[2]}")
fi
```
## 验证
使用 `roadmap get-phase` 验证阶段存在:
```bash
PHASE_CHECK=$(node "$HOME/.claude/msd-core/bin/msd-tools.cjs" roadmap get-phase "${PHASE}")
if [ "$(printf '%s\n' "$PHASE_CHECK" | jq -r '.found')" = "false" ]; then
echo "ERROR: Phase ${PHASE} not found in roadmap"
exit 1
fi
```
## 目录查找
使用 `find-phase` 进行目录查找:
```bash
PHASE_DIR=$(node "$HOME/.claude/msd-core/bin/msd-tools.cjs" find-phase "${PHASE}" --raw)
```