Claude Skill

pdlc-status

查看项目 PDLC 状态总览(读 docs/.pdlc-state/ 输出进度)

LLM Mart · 0 points · 0 views 0 listing impressions 0 install-command copies
Virus-scanned Reviewed automatically before listing.

Full trust report

Download kanfu-panda-pdlc-skills-skills_pdlc-status-3cd2f02.zip · 9 KB
Part of kanfu-panda/pdlc-skills — 36 skills

Install

skills CLI npx skills add https://github.com/kanfu-panda/pdlc-skills/tree/main/skills/pdlc-status
Claude Code claude plugin marketplace add https://llmmart.ai/marketplace.json && claude plugin install kanfu-panda-pdlc-skills@llmmart
Git git clone https://github.com/kanfu-panda/pdlc-skills.git

The skills CLI installs just this skill, for any of its supported agents. Claude Code installs the whole kanfu-panda/pdlc-skills collection as a plugin from our marketplace. Git is the plain clone.

Skill manifest

项目 PDLC 状态总览

读取 docs/.pdlc-state/ 目录下所有状态机文件,输出项目当前的 PDLC 进度、阶段分布、待办建议。

读状态机之前:先做契约体检

docs/.pdlc-state/*.json 不一定都是 /pdlc-* 命令写出来的——手写的、旧版本写的、照着格式仿写的 都可能混在里面。字段对不上契约时,不许边猜边算、再把猜出来的东西当结论。先体检,再计算; 体检发现的每一处偏差,都必须出现在输出的最前面

1. 跑体检

体检脚本随本 skill 一起分发,就在本 skill 目录下:scripts/pdlc-state-lint.sh(运行时会告知本 skill 的 所在目录)。它与正在运行的 skill 同一版本,体检规则——合法阶段名、偏差代码——与下方 §2 一致。

在项目根执行 bash <本 skill 目录>/scripts/pdlc-state-lint.sh .。stdout 每行一条偏差:文件<TAB>代码<TAB>说明。退出码三态:

  • 0 已体检、全部合契约 → 照常出结论,不输出体检块
  • 1 已体检、有偏差 → 照常计算,但输出最前面必须先放「输入契约体检」块(见 §3)
  • 2 无法体检(缺 jq / 无状态目录)→ 体检块写「无法体检:<原因>」,不得当成合契约

体检脚本不可用时(找不到,或当前平台没有随 skill 分发它),按 §2 的规则逐条人工核对, 体检块首行注明「体检脚本不可用,以下为人工核对」。

2. 体检规则(偏差代码)

读侧跳过 _ 前缀的索引文件(如 _relations.json)与 statusline.json,它们不是功能状态机。

代码 判定 读侧怎么处理
json-invalid 文件不是合法 JSON 跳过该文件,列入体检块
missing-field feature_id / current_stage / history / next_step / created_at 之一 用到该字段的指标,对这份文件记「不可判」
field-type-invalid 字段在、类型不对(如 current_stage 不是字符串、history 不是数组、last_phase_result 不是对象、history 条目不是对象) 按缺失处理:用到它的指标对这份文件记「不可判」。类型不对的时间戳不再另报 timestamp-no-time
missing-last_phase_result last_phase_result(多为旧文件) 不推断本阶段结果与 checks
terminal_state-in-instance 实例里出现 terminal_state 忽略该字段,判终态只看 §4
non-contract-field 其它表外顶层字段(如 title 忽略
stage-alias stage 用了已知别名 可按说明里的 别名→短名 归一化计数,但必须在体检块写明归一化了哪些
stage-unknown stage 既不是短名也不是已知别名 单独成行,不并入任何阶段
current_stage-unknown current_stage 既不是短名,也不以 _done 结尾 该功能归入「❓ 异常」
next_step-not-command next_step 不是纯命令名(如带散文后缀) 按原文展示,不据此推断下一步
timestamp-no-time 时间戳只有日期、没有时刻 依赖它的耗时类指标记「不可测」,不得算成 0
relations-not-object relations 不是六键对象(如数组) 这份文件的关系不入图,列入体检块
relations-unknown-type 关系键不在六类之内 该键下的关系不入图
relations-target-not-id 关系目标不是 feature ID(散文、模块路径等) 该条不入图
relations-dangling 目标 ID 没有对应的状态文件 标「悬空」,不参与影响半径计算
id-prefix-mismatch 走的是修复流程(有 fix 阶段),ID 却不以 B 开头 缺陷计数按 ID 前缀的契约口径算,同时在体检块点名这份
second-state-dir 仓库根另有一个 .pdlc-state/ 本命令只读 docs/.pdlc-state/,提示两处并存

「不入图」不是丢弃:关系目标是散文时,把它硬解读成某个 feature,等于把猜测升格成结构—— 影响半径会因此多出一条本不存在的强依赖。宁可在体检块里原样列出,交给人判断。

阶段短名全集

history[].stagelast_phase_result.stage 只能取下表的短名——每个短名由对应命令写入, 等于该命令 frontmatter 的 stage:。别名只为旧数据时容忍,归一化必须披露;的时候一律用短名。

短名 由哪个命令写入 已知别名(读侧可归一化,须披露)
requirements pdlc-prd prd
design pdlc-design
tdd pdlc-tdd
impl pdlc-implement implement, implementation
review pdlc-review
e2e pdlc-e2e
ship pdlc-ship
deploy pdlc-deploy
fix pdlc-fix bugfix
refactor pdlc-refactor
task pdlc-task
feature pdlc-feature

3. 体检块的格式(放在输出最前面)

⚠️ 输入契约体检:<N> 份状态文件,<M> 处偏差——以下结论建立在这些处理之上
  · 3/5 份缺 created_at → 时间窗改用 history 末条 done_at
  · 阶段别名 prd→requirements ×1、implementation→impl ×2 → 已归一化计数
  · 5/5 份含 terminal_state → 已忽略(判终态只看 current_stage)
  · 2 份的 done_at 只有日期 → 阶段耗时记「不可测」
  • 按「偏差类 × 份数 × 处理方式」汇总,不要把脚本输出原样倒出来
  • 放最前面,不放末尾——结论会被单独引用,偏差得跟着结论走;写在报告末尾的偏差表, 读者看到的时候已经信了前面的数字
  • 计数照抄脚本输出,不要自己重数:按代码计数用 cut -f2 | sort | uniq -c,份数按第一列去重。 真机验证时脚本报 25 处无时刻的时间戳,报告正文却自己数成了 26——同一份报告里两个数字对不上, 读者就不知道该信哪个
  • 同一次输出里,前面披露了「已忽略 X」,后面的计算就不得再用 X

4. 判终态的唯一依据 ⛔

已抵达终态 ⇔ current_stage_done 结尾(终态即「已发布」:/pdlc-shipship_done/pdlc-deploydeploy_done;旧版本留下的 feature_done / fix_done / review_done 也按终态读)。

  • 不看 terminal_state。状态机实例本就没有这个字段。skill frontmatter 里的 terminal_state: 说的是「这个命令走完后应当到达的终态名」——是目标,不是事实。拿它判终态, 等于把「打算完成」当成「已经完成」。
  • 不用封闭列表(如只认 [feature_done, fix_done])。封闭列表会把合法的终态漏判成「进行中」, 逼着读侧去别的字段里找答案——而最顺手的那个字段恰好就是 terminal_state
  • next_stepnull 也不等于终态/pdlc-task 写的 next_step 恒为 null,却未必完成;空的或残缺的状态文件也读得出 null

执行流程

1. 扫描状态机

  1. 列出 docs/.pdlc-state/*.json 所有文件(跳过 _ 前缀的索引文件与 statusline.json
  2. 若无文件 → 输出:📭 尚无 PDLC 追踪记录。运行 /pdlc-feature 或 /pdlc-fix 开始第一个功能。
  3. 跑契约体检(见上方「读状态机之前:先做契约体检」)。有偏差或无法体检时,体检块放在总览最前面
  4. 进入下一步

2. 解析与分类

current_stage 字段分组:

  • ✅ 已完成:current_stage_done 结尾——判终态的唯一依据,不看 terminal_state、不用封闭列表(见上方「判终态的唯一依据」)
  • 🚧 进行中:current_stage 有值且不以 _done 结尾
  • ❓ 异常:JSON 无法解析、缺 current_stage,或体检对 current_stagecurrent_stage-unknown / field-type-invalid

3. 输出概览

⚠️ 输入契约体检:<N> 份状态文件,<M> 处偏差——以下结论建立在这些处理之上
  · …(仅在体检有偏差或无法体检时出现,且必须放在最前面)

📊 PDLC 状态总览(共 <N> 个功能)

🚧 进行中(<M> 个)
  - F20260419-090000 user-auth      当前:design       下一步:/pdlc-tdd
  - F20260419-100000 pwd-reset      当前:impl         下一步:/pdlc-review

✅ 已完成(<K> 个)
  - F20260415-110000 feature-xyz    完成于 2026-04-16
  - B20260418-090000 login-crash    完成于 2026-04-18(ship_done)

⚠️ 待办建议
  - F20260419-090000 停留在 design 超过 2 天,建议推进 /pdlc-tdd

3.5 关系树视图(RFC#6)

若存在 docs/.pdlc-state/_relations.json,附加关系视图(读其 index 的 inbound/outbound):

🔗 关系链
  F20260419-090000 user-auth
    ├─ extends → F20260415-110000 feature-xyz
    └─ ← depended_on_by F20260419-100000 pwd-reset

  🧩 孤立 feature(无任何关系):F20260420-130000
  • 出边用 ,入边用 ← <反向类型>
  • 末尾列 orphans(inbound + outbound 均空的 feature)
  • _relations.json 不存在时跳过本节(Phase 1 向后兼容);Phase 2 起关系视图进入默认总览

4. 参数处理

  • 参数为空或为 --all → 输出所有功能
  • 参数为功能ID → 只输出该功能的详情(含 history 全量 + 该 feature 的关系)
  • --relations → 只输出关系树视图

参数

  • --all(默认):全部功能总览
  • <feature-id>:单个功能的完整 history
  • --relations:只输出关系树视图(出边 + 入边 + orphans)
  • --stale <days>:列出停留在同一阶段超过 <days> 天的功能(默认 3 天)

参数:$ARGUMENTS

Files (pdlc-skills)
  • scripts
    • pdlc-state-lint.sh 11.3 KB
      #!/usr/bin/env bash
      # pdlc-state-lint.sh —— 读状态机之前的契约体检(确定性、只读)
      #
      # 用法:bash pdlc-state-lint.sh [项目根目录]      (缺省为当前目录)
      #
      # 逐份读 <项目根>/docs/.pdlc-state/*.json,对照状态机契约,把每一处偏差打成一行:
      #     <文件名><TAB><偏差代码><TAB><说明>
      # 偏差代码的含义,以及读侧(/pdlc-status、/pdlc-retro、/pdlc-relate)该怎么处理,
      # 见 references/templates/prompts/state-read.md 的偏差代码表。
      #
      # 为什么要有它:状态文件不一定都是 /pdlc-* 命令写的。字段对不上契约时,读侧的模型只能
      # 边猜边算——曾有两个不同的命令各自拿 terminal_state(契约里没有这个字段)判终态,
      # 把「目标是完成」报成了「已经完成」。把体检做成代码,同样的输入永远得到同样的偏差清单,
      # 读侧只负责把它们披露在结论前面。
      #
      # 退出码三态(与 check 命令的三态同一条纪律——「查不了」绝不能当成「没问题」):
      #   0  已体检,全部合契约
      #   1  已体检,有偏差(读侧可以继续,但结论必须先披露这些偏差)
      #   2  无法体检:没有 docs/.pdlc-state/、缺 jq,或体检自身出错
      #
      # 只读:不写任何文件。兼容 macOS 自带的 bash 3.2(不用 mapfile / 关联数组)。
      set -u
      
      # 下面三份清单由 tests/frontmatter-check.sh 断言:
      #   LEGAL_STAGES / STAGE_ALIASES 必须与 state-read.md 的 stage-names 表一致;
      #   FINDING_CODES 必须与 state-read.md 的偏差代码表逐一对应。
      # 本脚本在目标项目里运行、读不到插件的 skills/,所以清单只能内嵌——断言保证它不漂。
      LEGAL_STAGES="requirements design tdd impl review e2e ship deploy fix refactor task feature"
      STAGE_ALIASES="prd:requirements implement:impl implementation:impl bugfix:fix"
      # shellcheck disable=SC2034  # 脚本自己不读它:它是偏差代码的声明清单,供 frontmatter-check 与片段对账
      FINDING_CODES="json-invalid missing-field field-type-invalid missing-last_phase_result terminal_state-in-instance non-contract-field stage-alias stage-unknown current_stage-unknown next_step-not-command timestamp-no-time relations-not-object relations-unknown-type relations-target-not-id relations-dangling id-prefix-mismatch second-state-dir"
      
      ROOT="${1:-.}"
      STATE_DIR="$ROOT/docs/.pdlc-state"
      
      if ! command -v jq >/dev/null 2>&1; then
          echo "pdlc-state-lint: 缺 jq,无法体检" >&2
          exit 2
      fi
      if [ ! -d "$STATE_DIR" ]; then
          echo "pdlc-state-lint: 没有 ${STATE_DIR},无法体检" >&2
          exit 2
      fi
      
      # 与状态栏同一条规则:_ 前缀是自动生成的索引(如 _relations.json),
      # statusline.json 是配置,都不是功能状态机
      is_state_file() {
          case "${1##*/}" in
              _*|statusline.json) return 1 ;;
          esac
          return 0
      }
      
      # 现存的 feature ID(= 状态文件名去掉 .json),供判断关系目标是否悬空
      ids=""
      for f in "$STATE_DIR"/*.json; do
          [ -e "$f" ] || continue
          is_state_file "$f" || continue
          b="${f##*/}"
          ids="${ids}${b%.json}
      "
      done
      ids_json="$(printf '%s' "$ids" | jq -R -s 'split("\n") | map(select(length > 0))')"
      
      files=0
      findings=0
      broken=0
      
      for f in "$STATE_DIR"/*.json; do
          [ -e "$f" ] || continue
          is_state_file "$f" || continue
          base="${f##*/}"
          files=$((files + 1))
      
          # 先单独判合法性:把「文件坏了」和「体检程序自己出错」分开,后者属于无法体检
          if ! jq empty "$f" >/dev/null 2>&1; then
              printf '%s\t%s\t%s\n' "$base" "json-invalid" "不是合法 JSON,已跳过"
              findings=$((findings + 1))
              continue
          fi
      
          if ! out="$(jq -r --arg legal "$LEGAL_STAGES" --arg aliases "$STAGE_ALIASES" --argjson ids "$ids_json" '
              def emit($c; $d): "\($c)\t\($d | tostring | gsub("[\t\r\n]"; " "))";
              def inarr($a; $x): ($a | map(. == $x) | any);
              def legal: ($legal | split(" "));
              def aliasmap: ($aliases | split(" ") | map(split(":") | {(.[0]): .[1]}) | add);
              def canon($v): (aliasmap[$v] // $v);
              def hastime: (type == "string") and test("T[0-9]{2}:[0-9]{2}");
              def sixkeys: ["extends", "depends_on", "supersedes", "resolves", "conflicts_with", "relates_to"];
              def allowed: ["feature_id", "feature_name", "created_at", "current_stage", "run_mode",
                            "history", "last_phase_result", "relations", "next_step"];
              def idre: "^[FB][0-9]{8}-([0-9]{6}|[0-9]{2})$";
              def hist: (.history | if type == "array" then to_entries[] | select(.value | type == "object") else empty end);
              # 字段在、类型不对:只查 has() 会把 current_stage 是数字、history 不是数组这类文件放过去
              def typecheck($k; $want):
                  select(has($k)) | .[$k] as $v | select(($v | type) != $want)
                  | emit("field-type-invalid"; "\($k) 应为 \($want),实际是 \($v | type),按缺失处理");
              def stage_check($where; $v):
                  if ($v | type) != "string" then empty
                  elif inarr(legal; $v) then empty
                  elif aliasmap[$v] != null then
                      emit("stage-alias"; "\($where)=\($v) 是别名,读侧按 \($v)→\(aliasmap[$v]) 归一化(须披露)")
                  else
                      emit("stage-unknown"; "\($where)=\($v) 既不是阶段短名也不是已知别名")
                  end;
      
              if type != "object" then emit("json-invalid"; "顶层不是 JSON 对象,已跳过")
              else
                ( ["feature_id", "current_stage", "history", "next_step", "created_at"][] as $k
                  | select(has($k) | not) | emit("missing-field"; "缺 \($k)") ),
                ( typecheck("feature_id"; "string"), typecheck("feature_name"; "string"),
                  typecheck("created_at"; "string"), typecheck("current_stage"; "string"),
                  typecheck("run_mode"; "string"), typecheck("history"; "array"),
                  typecheck("last_phase_result"; "object") ),
                ( .history | if type == "array" then
                    to_entries[] | select(.value | type != "object")
                    | emit("field-type-invalid"; "history[\(.key)] 应为 object,实际是 \(.value | type),该条跳过")
                  else empty end ),
                ( hist | .key as $i | .value
                  | ( select(has("stage") and (.stage | type) != "string")
                      | emit("field-type-invalid"; "history[\($i)].stage 应为 string,实际是 \(.stage | type)") ),
                    ( select(has("done_at") and (.done_at | type) != "string")
                      | emit("field-type-invalid"; "history[\($i)].done_at 应为 string,实际是 \(.done_at | type)") ) ),
                ( select((.last_phase_result | type) == "object") | .last_phase_result
                  | ( select(has("stage") and (.stage | type) != "string")
                      | emit("field-type-invalid"; "last_phase_result.stage 应为 string,实际是 \(.stage | type)") ),
                    ( select(has("at") and (.at | type) != "string")
                      | emit("field-type-invalid"; "last_phase_result.at 应为 string,实际是 \(.at | type)") ) ),
                ( select(has("last_phase_result") | not)
                  | emit("missing-last_phase_result"; "缺 last_phase_result(多为旧文件),不推断本阶段结果与 checks") ),
                ( select(has("terminal_state"))
                  | emit("terminal_state-in-instance"; "实例含 terminal_state=\(.terminal_state),它是目标不是事实,已忽略;判终态只看 current_stage") ),
                ( keys[] as $k | select($k != "terminal_state" and (inarr(allowed; $k) | not))
                  | emit("non-contract-field"; "表外字段 \($k),已忽略") ),
                ( hist | .key as $i | .value | stage_check("history[\($i)].stage"; .stage) ),
                ( select((.last_phase_result | type) == "object")
                  | stage_check("last_phase_result.stage"; .last_phase_result.stage) ),
                ( .current_stage as $cs | select(($cs | type) == "string")
                  | select(($cs | endswith("_done")) | not) | select(inarr(legal; $cs) | not)
                  | emit("current_stage-unknown"; "current_stage=\($cs) 既不是阶段短名,也不以 _done 结尾") ),
                ( select(has("next_step")) | .next_step as $n | select($n != null)
                  | select((($n | type) == "string" and ($n | test("^pdlc-[a-z][a-z-]*$"))) | not)
                  | emit("next_step-not-command"; "next_step=\($n) 不是纯命令名,不据此推断下一步") ),
                ( select((.created_at | type) == "string") | select(.created_at | hastime | not)
                  | emit("timestamp-no-time"; "created_at=\(.created_at) 没有时刻") ),
                ( hist | .key as $i | .value | select((.done_at | type) == "string") | select(.done_at | hastime | not)
                  | emit("timestamp-no-time"; "history[\($i)].done_at=\(.done_at) 没有时刻,耗时类指标不可测") ),
                ( select((.last_phase_result | type) == "object" and ((.last_phase_result.at | type) == "string"))
                  | select(.last_phase_result.at | hastime | not)
                  | emit("timestamp-no-time"; "last_phase_result.at=\(.last_phase_result.at) 没有时刻") ),
                ( select(has("relations")) | .relations as $r
                  | if ($r | type) == "object" then
                      ( $r | to_entries[] | select(.key != "_updated_at") | . as $e
                        | if (inarr(sixkeys; $e.key) | not) then
                            emit("relations-unknown-type"; "关系类型 \($e.key) 不在六类之内,不入图")
                          else
                            ($e.value | if type == "array" then .[] else . end) as $t
                            | if (($t | type) == "string" and ($t | test(idre))) then
                                ( select(inarr($ids; $t) | not)
                                  | emit("relations-dangling"; "\($e.key) → \($t),没有对应的状态文件") )
                              else
                                emit("relations-target-not-id"; "\($e.key) → \($t),目标不是 feature ID,不入图")
                              end
                          end )
                    elif $r == null then empty
                    else
                      emit("relations-not-object"; "relations 是 \($r | type)\(if ($r | type) == "array" then "(\($r | length) 条)" else "" end),契约要求六键对象;该文件的关系不入图")
                    end ),
                ( select([hist | .value.stage | select(type == "string") | canon(.)] | inarr(.; "fix"))
                  | select(((.feature_id // "") | tostring | startswith("B")) | not)
                  | emit("id-prefix-mismatch"; "history 有修复阶段,feature_id=\(.feature_id // "缺") 却不以 B 开头;缺陷计数仍按 ID 前缀口径") )
              end
          ' "$f" 2>/dev/null)"; then
              echo "pdlc-state-lint: 体检 ${base} 时出错(体检自身的问题),该文件未完成体检" >&2
              broken=1
              continue
          fi
      
          while IFS= read -r line; do
              [ -n "$line" ] || continue
              printf '%s\t%s\n' "$base" "$line"
              findings=$((findings + 1))
          done <<< "$out"
      done
      
      # 仓库根另有一个 .pdlc-state/:常见于先有一份轻量登记、后来又照格式建了 docs/.pdlc-state/ 的项目
      if [ -d "$ROOT/.pdlc-state" ]; then
          printf '%s\t%s\t%s\n' ".pdlc-state/" "second-state-dir" "仓库根另有一个 .pdlc-state/;PDLC 只读写 docs/.pdlc-state/,两处并存容易让人以为状态在另一处"
          findings=$((findings + 1))
      fi
      
      echo "pdlc-state-lint: ${files} 份状态文件,${findings} 处偏差" >&2
      
      [ "$broken" -eq 1 ] && exit 2
      [ "$findings" -gt 0 ] && exit 1
      exit 0
      
  • SKILL.md 10.1 KB
    ---
    name: pdlc-status
    description: 查看项目 PDLC 状态总览(读 docs/.pdlc-state/ 输出进度)
    argument-hint: [feature-id | --all]
    allowed-tools: Read, Glob, Bash
    layer: 1
    stage: ops
    produces: []
    requires: []
    next_step: null
    terminal_state: null
    ---
    
    # 项目 PDLC 状态总览
    
    读取 `docs/.pdlc-state/` 目录下所有状态机文件,输出项目当前的 PDLC 进度、阶段分布、待办建议。
    
    <!-- @include templates/prompts/state-read.md(已内联于下方,无需另读) -->
    ## 读状态机之前:先做契约体检
    
    `docs/.pdlc-state/*.json` 不一定都是 `/pdlc-*` 命令写出来的——手写的、旧版本写的、照着格式仿写的
    都可能混在里面。字段对不上契约时,**不许边猜边算、再把猜出来的东西当结论**。先体检,再计算;
    体检发现的每一处偏差,都必须出现在输出的**最前面**。
    
    ### 1. 跑体检
    
    体检脚本随本 skill 一起分发,就在本 skill 目录下:`scripts/pdlc-state-lint.sh`(运行时会告知本 skill 的
    所在目录)。它与正在运行的 skill 同一版本,体检规则——合法阶段名、偏差代码——与下方 §2 一致。
    
    在项目根执行 `bash <本 skill 目录>/scripts/pdlc-state-lint.sh .`。stdout 每行一条偏差:`文件<TAB>代码<TAB>说明`。退出码三态:
    
    - `0` 已体检、全部合契约 → 照常出结论,不输出体检块
    - `1` 已体检、有偏差 → 照常计算,但输出最前面必须先放「输入契约体检」块(见 §3)
    - `2` 无法体检(缺 jq / 无状态目录)→ 体检块写「无法体检:<原因>」,**不得当成合契约**
    
    体检脚本不可用时(找不到,或当前平台没有随 skill 分发它),按 §2 的规则逐条人工核对,
    体检块首行注明「体检脚本不可用,以下为人工核对」。
    
    ### 2. 体检规则(偏差代码)
    
    读侧跳过 `_` 前缀的索引文件(如 `_relations.json`)与 `statusline.json`,它们不是功能状态机。
    
    <!-- finding-codes:start -->
    | 代码 | 判定 | 读侧怎么处理 |
    |---|---|---|
    | `json-invalid` | 文件不是合法 JSON | 跳过该文件,列入体检块 |
    | `missing-field` | 缺 `feature_id` / `current_stage` / `history` / `next_step` / `created_at` 之一 | 用到该字段的指标,对这份文件记「不可判」 |
    | `field-type-invalid` | 字段在、类型不对(如 `current_stage` 不是字符串、`history` 不是数组、`last_phase_result` 不是对象、history 条目不是对象) | **按缺失处理**:用到它的指标对这份文件记「不可判」。类型不对的时间戳不再另报 `timestamp-no-time` |
    | `missing-last_phase_result` | 缺 `last_phase_result`(多为旧文件) | 不推断本阶段结果与 checks |
    | `terminal_state-in-instance` | 实例里出现 `terminal_state` | **忽略该字段**,判终态只看 §4 |
    | `non-contract-field` | 其它表外顶层字段(如 `title`) | 忽略 |
    | `stage-alias` | `stage` 用了已知别名 | 可按说明里的 `别名→短名` 归一化计数,**但必须在体检块写明归一化了哪些** |
    | `stage-unknown` | `stage` 既不是短名也不是已知别名 | 单独成行,不并入任何阶段 |
    | `current_stage-unknown` | `current_stage` 既不是短名,也不以 `_done` 结尾 | 该功能归入「❓ 异常」 |
    | `next_step-not-command` | `next_step` 不是纯命令名(如带散文后缀) | 按原文展示,不据此推断下一步 |
    | `timestamp-no-time` | 时间戳只有日期、没有时刻 | 依赖它的**耗时类指标记「不可测」**,不得算成 0 |
    | `relations-not-object` | `relations` 不是六键对象(如数组) | 这份文件的关系**不入图**,列入体检块 |
    | `relations-unknown-type` | 关系键不在六类之内 | 该键下的关系不入图 |
    | `relations-target-not-id` | 关系目标不是 feature ID(散文、模块路径等) | 该条不入图 |
    | `relations-dangling` | 目标 ID 没有对应的状态文件 | 标「悬空」,不参与影响半径计算 |
    | `id-prefix-mismatch` | 走的是修复流程(有 `fix` 阶段),ID 却不以 `B` 开头 | 缺陷计数按 ID 前缀的契约口径算,同时在体检块点名这份 |
    | `second-state-dir` | 仓库根另有一个 `.pdlc-state/` | 本命令只读 `docs/.pdlc-state/`,提示两处并存 |
    <!-- finding-codes:end -->
    
    **「不入图」不是丢弃**:关系目标是散文时,把它硬解读成某个 feature,等于把猜测升格成结构——
    影响半径会因此多出一条本不存在的强依赖。宁可在体检块里原样列出,交给人判断。
    
    #### 阶段短名全集
    
    `history[].stage` 与 `last_phase_result.stage` 只能取下表的短名——每个短名由对应命令写入,
    等于该命令 frontmatter 的 `stage:`。别名只为**读**旧数据时容忍,归一化必须披露;**写**的时候一律用短名。
    
    <!-- stage-names:start -->
    | 短名 | 由哪个命令写入 | 已知别名(读侧可归一化,须披露) |
    |---|---|---|
    | `requirements` | `pdlc-prd` | `prd` |
    | `design` | `pdlc-design` | |
    | `tdd` | `pdlc-tdd` | |
    | `impl` | `pdlc-implement` | `implement, implementation` |
    | `review` | `pdlc-review` | |
    | `e2e` | `pdlc-e2e` | |
    | `ship` | `pdlc-ship` | |
    | `deploy` | `pdlc-deploy` | |
    | `fix` | `pdlc-fix` | `bugfix` |
    | `refactor` | `pdlc-refactor` | |
    | `task` | `pdlc-task` | |
    | `feature` | `pdlc-feature` | |
    <!-- stage-names:end -->
    
    ### 3. 体检块的格式(放在输出最前面)
    
    ```
    ⚠️ 输入契约体检:<N> 份状态文件,<M> 处偏差——以下结论建立在这些处理之上
      · 3/5 份缺 created_at → 时间窗改用 history 末条 done_at
      · 阶段别名 prd→requirements ×1、implementation→impl ×2 → 已归一化计数
      · 5/5 份含 terminal_state → 已忽略(判终态只看 current_stage)
      · 2 份的 done_at 只有日期 → 阶段耗时记「不可测」
    ```
    
    - **按「偏差类 × 份数 × 处理方式」汇总**,不要把脚本输出原样倒出来
    - **放最前面,不放末尾**——结论会被单独引用,偏差得跟着结论走;写在报告末尾的偏差表,
      读者看到的时候已经信了前面的数字
    - **计数照抄脚本输出,不要自己重数**:按代码计数用 `cut -f2 | sort | uniq -c`,份数按第一列去重。
      真机验证时脚本报 25 处无时刻的时间戳,报告正文却自己数成了 26——同一份报告里两个数字对不上,
      读者就不知道该信哪个
    - 同一次输出里,前面披露了「已忽略 X」,后面的计算就不得再用 X
    
    ### 4. 判终态的唯一依据 ⛔
    
    **已抵达终态 ⇔ `current_stage` 以 `_done` 结尾**(终态即「已发布」:`/pdlc-ship` 写 `ship_done`、`/pdlc-deploy` 写 `deploy_done`;旧版本留下的 `feature_done` / `fix_done` / `review_done` 也按终态读)。
    
    - **不看 `terminal_state`**。状态机实例本就没有这个字段。skill frontmatter 里的 `terminal_state:`
      说的是「这个命令走完后**应当**到达的终态名」——是**目标**,不是**事实**。拿它判终态,
      等于把「打算完成」当成「已经完成」。
    - **不用封闭列表**(如只认 `[feature_done, fix_done]`)。封闭列表会把合法的终态漏判成「进行中」,
      逼着读侧去别的字段里找答案——而最顺手的那个字段恰好就是 `terminal_state`。
    - **`next_step` 为 `null` 也不等于终态**:`/pdlc-task` 写的 `next_step` 恒为 `null`,却未必完成;空的或残缺的状态文件也读得出 `null`。
    <!-- @include-end templates/prompts/state-read.md -->
    
    ## 执行流程
    
    ### 1. 扫描状态机
    
    1. 列出 `docs/.pdlc-state/*.json` 所有文件(跳过 `_` 前缀的索引文件与 `statusline.json`)
    2. 若无文件 → 输出:`📭 尚无 PDLC 追踪记录。运行 /pdlc-feature 或 /pdlc-fix 开始第一个功能。`
    3. **跑契约体检**(见上方「读状态机之前:先做契约体检」)。有偏差或无法体检时,体检块放在总览**最前面**
    4. 进入下一步
    
    ### 2. 解析与分类
    
    按 `current_stage` 字段分组:
    
    - ✅ 已完成:`current_stage` 以 `_done` 结尾——**判终态的唯一依据**,不看 `terminal_state`、不用封闭列表(见上方「判终态的唯一依据」)
    - 🚧 进行中:`current_stage` 有值且不以 `_done` 结尾
    - ❓ 异常:JSON 无法解析、缺 `current_stage`,或体检对 `current_stage` 报 `current_stage-unknown` / `field-type-invalid`
    
    ### 3. 输出概览
    
    ```
    ⚠️ 输入契约体检:<N> 份状态文件,<M> 处偏差——以下结论建立在这些处理之上
      · …(仅在体检有偏差或无法体检时出现,且必须放在最前面)
    
    📊 PDLC 状态总览(共 <N> 个功能)
    
    🚧 进行中(<M> 个)
      - F20260419-090000 user-auth      当前:design       下一步:/pdlc-tdd
      - F20260419-100000 pwd-reset      当前:impl         下一步:/pdlc-review
    
    ✅ 已完成(<K> 个)
      - F20260415-110000 feature-xyz    完成于 2026-04-16
      - B20260418-090000 login-crash    完成于 2026-04-18(ship_done)
    
    ⚠️ 待办建议
      - F20260419-090000 停留在 design 超过 2 天,建议推进 /pdlc-tdd
    ```
    
    ### 3.5 关系树视图(RFC#6)
    
    若存在 `docs/.pdlc-state/_relations.json`,附加关系视图(读其 index 的 inbound/outbound):
    
    ```
    🔗 关系链
      F20260419-090000 user-auth
        ├─ extends → F20260415-110000 feature-xyz
        └─ ← depended_on_by F20260419-100000 pwd-reset
    
      🧩 孤立 feature(无任何关系):F20260420-130000
    ```
    
    - 出边用 `→`,入边用 `← <反向类型>`
    - 末尾列 orphans(inbound + outbound 均空的 feature)
    - `_relations.json` 不存在时跳过本节(Phase 1 向后兼容);Phase 2 起关系视图进入默认总览
    
    ### 4. 参数处理
    
    - 参数为空或为 `--all` → 输出所有功能
    - 参数为功能ID → 只输出该功能的详情(含 history 全量 + 该 feature 的关系)
    - `--relations` → 只输出关系树视图
    
    ## 参数
    
    - `--all`(默认):全部功能总览
    - `<feature-id>`:单个功能的完整 history
    - `--relations`:只输出关系树视图(出边 + 入边 + orphans)
    - `--stale <days>`:列出停留在同一阶段超过 `<days>` 天的功能(默认 3 天)
    
    ---
    
    **参数**:$ARGUMENTS
    

Comments (0)

Sign in to join the conversation.

No comments yet.

Reviews (0)

No reviews yet.

Related