@xulthekl/team-flow 0.65.0 → 0.67.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/.claude/always/phase-guard.md +1 -1
  2. package/.claude-plugin/marketplace.json +1 -1
  3. package/.claude-plugin/plugin.json +1 -1
  4. package/.codex-plugin/plugin.json +1 -1
  5. package/.cursor-plugin/marketplace.json +1 -1
  6. package/.cursor-plugin/plugin.json +1 -1
  7. package/.github/plugin/marketplace.json +2 -2
  8. package/CHANGELOG.md +31 -0
  9. package/GEMINI.md +1 -1
  10. package/INSTALL.md +1 -1
  11. package/README.md +1 -1
  12. package/agents/architecture-reviewer.md +4 -0
  13. package/agents/prd-completeness-reviewer.md +10 -0
  14. package/agents/prd-writer.md +1 -0
  15. package/agents/release-archivist.md +2 -0
  16. package/docs/README_en.md +1 -1
  17. package/docs/team-flow /344/275/277/347/224/250/350/257/264/346/230/216/357/274/210/347/240/224/345/217/221/345/233/242/351/230/237/347/211/210/357/274/211.md" +8 -6
  18. package/gemini-extension.json +1 -1
  19. package/hooks/session-start +2 -2
  20. package/llms.txt +1 -1
  21. package/package.json +1 -1
  22. package/plugin.json +1 -1
  23. package/prd/v1/prd.md +1 -1
  24. package/scripts/guard/checks/history-risk.mjs +132 -0
  25. package/scripts/guard/checks/prd-clarity-state.mjs +41 -0
  26. package/scripts/guard/checks/prd-clarity.mjs +176 -0
  27. package/scripts/guard/guard.mjs +16 -8
  28. package/scripts/infer-workflow.mjs +20 -0
  29. package/scripts/lib/cmd-doctor.mjs +2 -2
  30. package/scripts/lib/cmd-prd.mjs +84 -1
  31. package/scripts/lib/cmd-solutions.mjs +3 -0
  32. package/scripts/lib/cmd-state.mjs +31 -1
  33. package/scripts/lib/solutions-capture.mjs +5 -0
  34. package/scripts/lib/solutions-index-gen.mjs +33 -3
  35. package/scripts/lib/solutions-inject.mjs +34 -9
  36. package/scripts/lib/state-loader.mjs +13 -0
  37. package/skills/ce-brainstorm/SKILL.md +3 -3
  38. package/skills/ce-brainstorm/references/grounding.md +1 -1
  39. package/skills/ce-brainstorm/references/prd-84-authoring-spec.md +26 -3
  40. package/skills/ce-brainstorm/references/prototype-loop.md +8 -0
  41. package/skills/ce-compound/references/promotion-rules.md +1 -1
  42. package/skills/ce-compound/references/three-tier-index.md +1 -1
  43. package/skills/ce-plan/references/research-workflow.md +1 -1
  44. package/skills/jarvis/references/protocols.md +1 -0
  45. package/skills/workflow-orchestrator/SKILL.md +6 -2
  46. package/skills/workflow-orchestrator/references/s1-path-router.md +7 -0
  47. package/skills/workflow-orchestrator/references/s2-prd-prototype-loop.md +16 -2
  48. package/skills/workflow-orchestrator/references/s3-plan-pipeline.md +1 -1
  49. package/skills/workflow-start/SKILL.md +1 -1
  50. package/templates/prd.md +9 -1
@@ -37,16 +37,31 @@ import { severityRank } from './severity.mjs';
37
37
  import { parseTableRow } from './md-normalize.mjs';
38
38
 
39
39
  /**
40
- * INDEX 表列数范围(date | phase | domain | type | severity | summary | file [| source])。
41
- * v0.57.0 P4:`source` 列是本版新增 ⇒ 7(存量 INDEX)与 8(本版重建)都要接受。
40
+ * INDEX 表列数范围(date | phase | domain | type | severity | summary | file | source | flags)。
41
+ * v0.57.0 P4:`source` 列新增 ⇒ 7/8 都要接受;
42
+ * agent-governance P2-2:`flags` 列(见习/毕业)新增 ⇒ 8(上版重建)与 9(本版)都要接受,
43
+ * **7 列最旧存量同样接受**(flags 缺失 = 无锚存量 = grandfather auto-ok,见 index-gen deriveFlags)。
42
44
  */
43
45
  const INDEX_COLUMNS_MIN = 7;
44
- const INDEX_COLUMNS_MAX = 8;
46
+ const INDEX_COLUMNS_MAX = 9;
45
47
  /** `file` 列的形状(`<phase>/<name>.md`)——语义校验,见下方列解析注释 */
46
48
  const ENTRY_FILE_RE = /^[a-z][a-z-]*\/.+\.md$/;
47
49
  /** 默认展示条数 */
48
50
  const DEFAULT_LIMIT = 5;
49
51
 
52
+ /**
53
+ * P2-2 红区硬排除:DP-A / Code Landing / publish 相关的复利建议**永不自动注入**
54
+ * (memo §2.4 红区护栏——红区永久人工,连"建议"也不自动进上下文,防复利通道
55
+ * 变相给红区动作背书)。宁可少注入(安全方向)不误放。
56
+ */
57
+ const RED_ZONE_RE = /\bDP-A\b|Code Landing|\bpublish\b|发布闸|代码落地/i;
58
+
59
+ /** P2-2 见习判定:flags 列非 auto-ok(probation 或未知新值)即不自动注入。 */
60
+ function isProbation(flags) {
61
+ const f = String(flags || '').toLowerCase();
62
+ return f !== '' && f !== 'auto-ok';
63
+ }
64
+
50
65
  export function run(args = {}) {
51
66
  const phase = args.phase || 'cross-phase';
52
67
  const domain = args.domain || '';
@@ -63,6 +78,8 @@ export function run(args = {}) {
63
78
 
64
79
  const content = readFileSync(indexPath, 'utf-8');
65
80
  const entries = [];
81
+ // P2-2 门控计数(可观察性:跳过多少 = 门在工作的证据)
82
+ const excluded = { probation: 0, redZone: 0 };
66
83
 
67
84
  for (const line of content.split('\n')) {
68
85
  if (!line.startsWith('|') || line.startsWith('| date') || line.startsWith('|--')) continue;
@@ -70,7 +87,7 @@ export function run(args = {}) {
70
87
  const cells = parseTableRow(line);
71
88
  // 上下界同时校验:只查下界无法发现"summary 含 `|` 导致列数变多、file 列错位"(v0.38.0 test-merge 同型缺陷)
72
89
  if (cells.length < INDEX_COLUMNS_MIN || cells.length > INDEX_COLUMNS_MAX) continue;
73
- const [date, ePhase, eDomain, type, severity, summary, file, source = ''] = cells;
90
+ const [date, ePhase, eDomain, type, severity, summary, file, source = '', flags = ''] = cells;
74
91
  // file 列语义校验(v0.57.0 P4):列数在界内仍可能错位——例如 summary 含**未转义**的 `|`
75
92
  // 时列数恰好落进 7/8 区间,摘要后半段会顶到 file 位。形状不符即丢弃,避免注入错位的路径。
76
93
  if (!ENTRY_FILE_RE.test(file)) continue;
@@ -79,7 +96,10 @@ export function run(args = {}) {
79
96
  const domainMatch = !domain || !eDomain || eDomain === 'general' || eDomain === domain;
80
97
 
81
98
  if (phaseMatch && domainMatch) {
82
- entries.push({ date, phase: ePhase, domain: eDomain, type, severity, summary, file, source, isNative: ePhase === phase });
99
+ // P2-2 两道消费侧门控(跳过 = 不注入,落 excluded 计数可观察)
100
+ if (isProbation(flags)) { excluded.probation += 1; continue; }
101
+ if (RED_ZONE_RE.test(`${summary} ${eDomain}`)) { excluded.redZone += 1; continue; }
102
+ entries.push({ date, phase: ePhase, domain: eDomain, type, severity, summary, file, source, flags, isNative: ePhase === phase });
83
103
  }
84
104
  }
85
105
 
@@ -119,12 +139,17 @@ export function run(args = {}) {
119
139
  const shown = all ? clustered : clustered.slice(0, limit);
120
140
 
121
141
  if (shown.length === 0) {
122
- console.log(`<!-- No matching solutions found (phase=${phase}, domain=${domain || 'any'}) -->`);
123
- return { entries: [] };
142
+ // P2-2:「被门控排除成空」与「本来无匹配」语义不同——前者必须可见,否则门 = 隐形
143
+ const excl = (excluded.probation + excluded.redZone) > 0
144
+ ? `(P2-2 门控排除 ${excluded.probation} 条见习 + ${excluded.redZone} 条红区)` : '';
145
+ console.log(`<!-- No matching solutions found (phase=${phase}, domain=${domain || 'any'})${excl} -->`);
146
+ return { entries: [], excluded };
124
147
  }
125
148
 
126
149
  const foldedNote = foldedCount > 0 ? `, ${foldedCount} 条同源已折叠` : '';
127
- console.log(`## Solutions Context (phase=${phase}, domain=${domain || 'any'}, showing ${shown.length}/${clustered.length}${foldedNote})`);
150
+ const excludedNote = (excluded.probation + excluded.redZone) > 0
151
+ ? `, P2-2 门控排除 ${excluded.probation} 条见习 + ${excluded.redZone} 条红区` : '';
152
+ console.log(`## Solutions Context (phase=${phase}, domain=${domain || 'any'}, showing ${shown.length}/${clustered.length}${foldedNote}${excludedNote})`);
128
153
  console.log('');
129
154
  for (const e of shown) {
130
155
  console.log(`- [${e.severity}] ${e.summary} (${e.phase}/${e.domain}, ${e.date}) → ${e.file}`);
@@ -140,7 +165,7 @@ export function run(args = {}) {
140
165
  console.log('');
141
166
  }
142
167
 
143
- return { entries: shown, total: clustered.length, folded: foldedCount, hidden };
168
+ return { entries: shown, total: clustered.length, folded: foldedCount, hidden, excluded };
144
169
  }
145
170
 
146
171
  if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
@@ -89,6 +89,11 @@ const BUILTIN_DEFAULTS = {
89
89
  test_matrix_skip_reason: null,
90
90
  // Test evidence (v0.13 §50:tf test record 落盘的 runner 输出证据路径)
91
91
  test_evidence_path: null,
92
+ // Product-level PRD clarity record(agent-governance P1-1 跨层管道):
93
+ // 唯一写入路径 = tf state init 从 <root>/.team-flow/prd-clarity.json 拷贝;
94
+ // **有意不在 cmd-state SETTABLE_FIELDS**——可 set 就是自助放行通道(gate-hint-is-a-bypass)。
95
+ prd_clarity_result: null,
96
+ prd_clarity_hash: null,
92
97
  // Tasks gate (v0.22 §85:hotfix/tweak 跳过 spec-writer 时显式跳过 tasks.md)
93
98
  tasks_skipped: null,
94
99
  tasks_skip_reason: null,
@@ -184,6 +189,14 @@ export function writeState(changeDir, state) {
184
189
  lines.push('# === Hashes (fast staleness detection) ===');
185
190
  lines.push(`artifacts_hash: ${state.artifacts_hash ?? 'null'}`);
186
191
  lines.push(`contract_hash: ${state.contract_hash ?? 'null'}`);
192
+ // P1-1 clarity 管道:条件序列化(同 schema_version 模式)——存量 change 无记录不追加,
193
+ // readState 缺失回退 BUILTIN_DEFAULTS 的 null(= 变更级维度中性)。
194
+ if (state.prd_clarity_result != null) {
195
+ lines.push(`prd_clarity_result: ${state.prd_clarity_result}`);
196
+ }
197
+ if (state.prd_clarity_hash != null) {
198
+ lines.push(`prd_clarity_hash: ${state.prd_clarity_hash}`);
199
+ }
187
200
  lines.push('');
188
201
  lines.push('# === Execution progress ===');
189
202
  lines.push(`execution_mode: ${state.execution_mode ?? 'null'}`);
@@ -195,13 +195,13 @@ For detailed routing logic, read `references/phase0-routing.md`. Summary:
195
195
  - **0.1b Classify**: software → continue; non-software → `references/universal-brainstorming.md`; neither → respond directly
196
196
  - **0.1c Verdict**: verdict-shaped requests → offer `/ce-pov` handoff via `references/verdict-routing.md`
197
197
  - **0.2 Assess**: clear requirements → skip to Phase 2.5; ambiguous → full brainstorm
198
- - **0.3 Scope**: Lightweight / Standard / Deep (+ feature vs product); arm visual-probe and blindspot tripwires
198
+ - **0.3 Scope**: Lightweight / Standard / Deep (+ feature vs product); arm visual-probe and blindspot tripwires. **Scope 推荐降阈值(agent-governance P1-2 · A 档)**:需求一句话可述、无跨模块疑点、`arch_baseline` 已建档时,**默认推荐 Lightweight**(跳 BP-1~3 + Path A 轻确认),用户确认即走;含糊/多义/涉新模块 → 推荐 Standard(含糊才升 Deep)。推荐是建议非决定,用户可任选档位;**判定不清时按 Standard 起步**(宁多问不漏问)。
199
199
  - **0.4 Spine**: create 5-task tracking spine for Standard/Deep
200
200
  - **0.5 Iteration**: resolve `ITERATION_VERSION` from `requirement/` directory (legacy: fallback `prd/`)
201
201
 
202
202
  ### Phase 1: Understand the Idea
203
203
 
204
- **1.1 Context Scan** — For Standard/Deep, dispatch grounding scout sub-agent (extraction-tier) to produce a grounding dossier. For the scout prompt, scratch directory setup, and Slack routing, read `references/grounding.md`. Two rules: **verify before claiming** (check infrastructure exists) and **defer design to planning**.
204
+ **1.1 Context Scan** — For Standard/Deep, dispatch grounding scout sub-agent (extraction-tier) to produce a grounding dossier. For the scout prompt, scratch directory setup, and Slack routing, read `references/grounding.md`. Two rules: **verify before claiming** (check infrastructure exists) and **defer design to planning**. **复利注入(P2-3 顶层调用,不限 scope)**:Phase 1 开始前跑 `tf solutions inject --phase prd --limit 5`(CLI 内含见习/红区门控;**Lightweight 同样注入**——它是轻命令,不随 scout 一起被 scope 门掉,防 A 档默认轻档路径零注入);空结果静默跳过——冷启动不计收益 0。
205
205
 
206
206
  **1.2 Pressure Test** — Scan opening for rigor gaps (evidence, specificity, counterfactual, attachment). Read `references/product-pressure-test.md` for per-tier lens catalog. Session-settled decisions count as already-probed.
207
207
 
@@ -273,7 +273,7 @@ Read `references/brainstorm-sections.md` for doc-warranted criteria. If warrante
273
273
 
274
274
  ### QA-4: PRD Quality Check
275
275
 
276
- Fires after Phase 3 (or Phase 3.5 if prototype loop ran). Read `references/evidence-chain-validation.md` for QA-4 criteria. Evaluates PRD completeness and traceability against business analysis artifacts. **冻结前完整性评审(6 维,含 §8.4 信息齐备性与业务可读形态 D6)的派发点已归并**:standalone 路径由 Phase 3.5(`references/prototype-loop.md` §3.5.5)派发 prd-completeness-reviewer;orchestrated 路径由 orchestrator S2 派发(见 `workflow-orchestrator/references/s2-prd-prototype-loop.md`);**QA-4 自身不重复派发**,仅按评审结果判定是否回 Phase 1.3/Phase 3 修订。
276
+ Fires after Phase 3 (or Phase 3.5 if prototype loop ran). Read `references/evidence-chain-validation.md` for QA-4 criteria. Evaluates PRD completeness and traceability against business analysis artifacts. **冻结前完整性评审(6 维,含 §8.4 信息齐备性与业务可读形态 D6)的派发点已归并**:standalone 路径由 Phase 3.5(`references/prototype-loop.md` §3.5.5)派发 prd-completeness-reviewer;orchestrated 路径由 orchestrator S2 派发(见 `workflow-orchestrator/references/s2-prd-prototype-loop.md`);**QA-4 自身不重复派发**,仅按评审结果判定是否回 Phase 1.3/Phase 3 修订。**冻结前先过清晰度机械门 `tf prd check-clarity`(P0-1,checker 先于 reviewer,FAIL 则回改不派发)**——调用细则见 `references/prototype-loop.md` §3.5.5 前置段(standalone)/ `s2-prd-prototype-loop.md` step 3.4(orchestrated)。
277
277
 
278
278
  ### Phase 3.6: PRD ↔ Scenario/Process Bidirectional Validation
279
279
 
@@ -9,7 +9,7 @@ Detailed context scanning logic for Phase 1.1. The main SKILL.md describes the h
9
9
  **Standard and Deep** — Two passes:
10
10
 
11
11
  *Constraint Check (inline)* — Use the project's active instructions and conventions already in your context. Read `STRATEGY.md` if it exists for product direction and `CONCEPTS.md` if it exists for canonical vocabulary — it lives at **`docs/architecture/CONCEPTS.md`** (the repo-root location was retired in v0.23.0, so a root-only probe misses bootstrapped projects). Use canonical names in dialogue, approaches, and the Product Contract.
12
- - **Solutions index (v0.5)**: Read `docs/solutions/INDEX.md` if it exists. Filter entries where `phase = prd OR phase = cross-phase` and `domain` matches the current topic. Inject the **top 5** summaries as context constraints, ordered **severity → phase-match → date** (the CLI's ordering). Widen the window with `tf solutions inject --phase prd --limit <n>` when cross-phase entries saturate it — otherwise this stage's own entries are unreachable. If INDEX.md does not exist or is empty, skip silently — a missing index makes the CLI print one WARN, which is not an error.
12
+ - **Solutions index (v0.5)**: Run `tf solutions inject --phase prd --limit 5` first(CLI 内含 P2-2 见习/红区门控); only if the CLI is unavailable, fall back to reading `docs/solutions/INDEX.md` manually — filter `phase = prd OR cross-phase` + domain match, top 5, ordered **severity → phase-match → date**. **手动降级不降门(P2-2)**:跳过 `flags=probation`(见习)行与红区关键词行(`DP-A`/`Code Landing`/`publish`/`发布闸`/`代码落地`)。If INDEX.md does not exist or is empty, skip silently — a missing index makes the CLI print one WARN, which is not an error(冷启动不计收益 0)。
13
13
 
14
14
  ## Topic Scan (Grounding Scout)
15
15
 
@@ -66,6 +66,11 @@
66
66
 
67
67
  **禁止**:把字段信息写成跨句的散文;**允许**:字段表(更推荐)、编号列表中的单行「字段:规则」。
68
68
 
69
+ **撰写指引剥离(模板实例化,P0-1 同步)**:模板(`templates/prd.md`)中的 `>` 元指令指引段
70
+ (「语汇/精确/完整性」「可解析性」及剥离规则自身)**不写入 PRD 正文**——它们是给撰写者的指令,
71
+ 且自带弱词示例,保留会触发冻结前 `tf prd check-clarity` FAIL(无豁免通道)。执行者侧同步声明见
72
+ `prd-writer` agent 禁令清单。
73
+
69
74
  ---
70
75
 
71
76
  ## 3. 六条生成原则
@@ -99,12 +104,27 @@
99
104
 
100
105
  ## 4. 精确性(弱词规则)
101
106
 
102
- **禁用**:比较级(较快 / 更好)、主观词(友好 / 简洁)、歧义词(支持 / 处理 / 适当)、
103
- 开放式(等 / 尽可能 / 视情况)、漏洞词(必要时 / 一般)。
107
+ **禁用(8 类,ISO/IEC/IEEE 29148 弱词规则;v0.65 后勘误扩全——checker 按本 8 类扫描)**:
108
+ 1. **比较级与最高级**(较快 / 更好 / 最快)——给出比较基准与具体数值;
109
+ 2. **主观评价词**(友好 / 简洁 / 易用 / 美观)——改为可观察的行为描述;
110
+ 3. **歧义词**(支持 / 处理 / 适当 / 尽量 / 总是 / 必要时)——明确条件与边界;
111
+ 4. **开放式表述**(等 / 尽可能 / 视情况 / 至少 / 不限于)——列出确切实例;
112
+ 5. **漏洞词**(可能 / 如适用 / 一般 / 通常)——明确触发条件;
113
+ 6. **否定句单独出现**(「不支持 X」)——改为「当 X 时,系统执行 Y」;
114
+ 7. **连接歧义**(「A 和/或 B」)——拆分条目或用决策表;
115
+ 8. **被动语态**(「应被校验」)——明确动作主体。
104
116
 
105
117
  **理由**:PRD 是下游(plan / spec / 代码生成)的输入。模糊表述**不会**被当作"待澄清",
106
118
  **会被下游自行解释**,产生静默缺陷。精确不是洁癖,是正确性的前提。
107
119
 
120
+ > **机械门校准注(2026-09-25)**:示例词中 **「处理」**(机械扫描会命中模板段名
121
+ > 「系统功能处理说明书」→ 死循环)与 **单字「等」**(子串命中「等待/等于」等一切含字场景)
122
+ > **刻意不入** `prd-clarity.mjs` 机械词表——这两词的判读由 LLM 审查层(prd-completeness-reviewer
123
+ > 精确性检查)覆盖;机械词表对 §4 的其余示例词全量收录。调词表须同步本节(单真相源)。
124
+
125
+ > 第 6–8 类为 2026-09-25 随 DEC-8a 复议补齐(原仅 5 类散文;8 类全集此前散落在工作区
126
+ > 设计文档的镜像弱词表中——单真相源裁定后全集收口于本节)。
127
+
108
128
  ---
109
129
 
110
130
  ## 5. 完整性:内部校验清单(**不写入正文**)
@@ -161,7 +181,10 @@ UI **11 维**:页面布局 / 权限规则 / 区块说明 / 搜索模块 / 表
161
181
  | 4 | 无弱词(见 §4) |
162
182
  | 5 | 维度清单未写入正文(见 §5) |
163
183
 
164
- > **非脚本门禁**:本节不得接入机械门禁脚本(弱词检测先落 LLM 审查层)。
184
+ > **勘误(2026-09-25,DEC-8a 推翻,Q5)**:弱词检测**已**落地机械门 `scripts/guard/checks/prd-clarity.mjs`
185
+ > (`tf prd check-clarity`,冻结前调用)——本文件 §4 为其**规则权威正文**,写 PRD 与调 checker 都以本节为准。
186
+ > LLM 审查层保留并存(checker 管机械可判定项,prd-completeness-reviewer 管语义完整性)。
187
+ > 机械门不检的其余自查节(可读性自查等)仍非脚本门禁。
165
188
 
166
189
  ---
167
190
 
@@ -39,6 +39,14 @@ PRD 文档写入后、Handoff 之前,执行原型内循环。原型是 PRD 的
39
39
 
40
40
  ## 3.5.5 PRD 完整性评审(冻结前门禁,v0.47 全路径适用)
41
41
 
42
+ **前置机械门(agent-governance P0-1,checker 先跑)**:派发 reviewer **之前**先运行清晰度机械门:
43
+
44
+ ```
45
+ tf prd check-clarity <工作区根> # 自动定位 requirement/vN/prd.md
46
+ ```
47
+
48
+ 末行 `STATUS: PASS | FAIL`(FAIL 时退出码非零)——**FAIL → 直接回 Phase 1.3/Phase 3 修订,不派发 reviewer**(机械门已拦,省一轮 LLM 评审);PASS → 继续下方派发。判据与豁免边界见 `scripts/guard/checks/prd-clarity.mjs` 头注(首版无豁免通道:误报改 PRD 或走代码变更调词表)。
49
+
42
50
  **所有 standalone 路径的冻结前必过门禁**:有原型(原型审查通过后)、无 UI 功能点(§3.5.1)、用户跳过原型(§3.5.1)三条路径均须派发——不因跳过原型循环而跳过完整性评审(orchestrated 路径对应 `s2-prd-prototype-loop.md` step 3.5)。
43
51
 
44
52
  派发 `prd-completeness-reviewer` 子代理(独立上下文),评审 PRD「是否完整到能支撑后续 plan/spec 实施」(区别于 Phase 2.6 claim verifier——后者管"说得对不对",本评审管"说得全不全")。
@@ -18,7 +18,7 @@ tf solutions promote <change-dir>
18
18
 
19
19
  满足以下条件的经验从 change 级别晋升到全局 `docs/solutions/`:
20
20
 
21
- - **severity ≥ medium** 且 **type = pitfall 或 pattern** → 晋升到全局 `docs/solutions/<phase>/`
21
+ - **severity ≥ medium** 且 **type = pitfall 或 pattern** → 晋升到全局 `docs/solutions/<phase>/`(`type = correction` 不适用本判定——P2-1 纠错条目由 `tf solutions capture` **直写全局**,不经晋升;其自动注入资格由 P2-2 见习/毕业机制按 confirmations 独立管理)
22
22
  - 与既有条目**文件名与正文签名都相同** → 同一条经验:登记来源 change + 升级 severity(见下「同名条目确认」),**不新建文件**
23
23
  - 与既有条目**同标题但正文不同** → **另一条**经验:新建条目(文件名加 `-2`/`-3` 后缀)——**正文不合并**
24
24
 
@@ -35,7 +35,7 @@ docs/solutions/
35
35
  ---
36
36
  phase: prd # 阶段标签:prd | plan | architecture | prototype | spec | build | review | cross-phase
37
37
  domain: auth # 领域标签(与 PRD/change 的领域对应)
38
- type: pitfall # pitfall | pattern | insight(仅 pitfall/pattern 参与晋升;其余保留在 change 级)
38
+ type: pitfall # pitfall | pattern | insight | correction(correction = P2-1 纠错捕获类,由 capture 直写全局、不经晋升判定;仅 pitfall/pattern 参与 promote 晋升,其余保留在 change 级)
39
39
  severity: high # critical | high | medium | low(序定义于 scripts/lib/severity.mjs)
40
40
  date: 2026-07-15
41
41
  source: change-id # 首次晋升的来源 change
@@ -45,7 +45,7 @@ Collect:
45
45
  - **Tools available + user didn't ask**: Note in output: "Slack tools detected. Ask me to search Slack for organizational context at any point, or include it in your next prompt."
46
46
  - **No tools + user asked**: Note in output: "Slack context was requested but no Slack tools are available. Install and authenticate the Slack plugin to enable organizational context search."
47
47
 
48
- **Solutions index (v0.5)**: Read `docs/solutions/INDEX.md` if it exists. Filter entries where `phase = plan OR phase = cross-phase` and `domain` matches the current topic. Inject the **top 5** summaries as planning constraints, ordered **severity → phase-match → date** (the CLI's ordering); widen with `tf solutions inject --phase plan --limit <n>` when cross-phase entries saturate the window. If INDEX.md does not exist or is empty, skip silently — a missing index makes the CLI print one WARN, which is not an error.
48
+ **Solutions index (v0.5)**: Run `tf solutions inject --phase plan --limit 5` first(CLI 内含见习/红区门控); only if the CLI is unavailable, fall back to reading `docs/solutions/INDEX.md` manually — filter `phase = plan OR cross-phase` + domain match, top 5, ordered **severity → phase-match → date**; widen with `--limit <n>` when cross-phase saturates the window. **手动降级不降门(P2-2)**:跳过 `flags=probation`(见习)行与红区关键词行(`DP-A`/`Code Landing`/`publish`/`发布闸`/`代码落地`)。If INDEX.md does not exist or is empty, skip silently — a missing index makes the CLI print one WARN, which is not an error(冷启动不计收益 0)。
49
49
 
50
50
  ## 1.1b Detect Execution Direction Signals
51
51
 
@@ -79,6 +79,7 @@
79
79
  | ② worker | 停止当前 change 推进;不提交半成品;已落 worktree 的工作**保留** |
80
80
  | ③ worker 记录 | **不写任何决策点字段**。两条禁令:① `dp_N_result` 是门禁判据(`dp-gate-passed` 只校验非空),写入 HOLD 值会让 change 呈现"已批准"假象;② `dp_{1,2,3,5,6,7}_decisions` 与 `dp_{1,2,3,5,6,7}_confirmed`(共 12 个)**已于 v0.59.0 移出 `cmd-state.mjs` 的 `SETTABLE_FIELDS` 白名单**——写入即显式报错 `⛔ Field '...' is not settable` 并以非 0 退出(**原为「回显 ✅ 却零写入」的静默假成功,v0.59.0 P4 实测后改为 fail-loud**;`dp_0_decisions`/`dp_0_confirmed` 不在移除之列,二者确有序列化分支)。HOLD 的持久锚点 = 步④ 的 escalation 消息 + 步⑥ 的 Jarvis 决策日志 + change 的 `state` 仍停在门禁前(客观事实)。**约束**:不得新建 `changes/<name>/` 下任何文件(Artifact Ownership:「主会话」此处指 **worker 侧**的主会话——它 MUST NOT 直接 Edit/Write `changes/` 或 `.worktrees/`;与 Jarvis 侧会话无关) |
81
81
  | ④ worker 上报 | `orca orchestration send --type escalation --subject "HOLD at <门>" --body "<摘要>" --json` |
82
+ | ④' 纠错捕获(**条件触发**,agent-governance P2-1) | HOLD 原因属「本可避免的错误」(方案踩坑/判据误判/返工教训,而非需求变更或外部依赖)时,worker 在上报后执行一次纪律级捕获:`tf solutions capture --phase <prd\|build\|review\|cross-phase> --domain <域> --type correction --severity <high\|medium> --summary "<规则化教训:什么场景 + 错误动作 + 正确做法>" --source-event <escalation msg_id 或决策日志行>`。**纪律级 = 无自动钩子**(pre-tool-use-guard 观测不到 HOLD、状态转换在 HOLD 时也不发生——两候选已证伪),漏捕获可接受、**误捕获(噪声条目)不可接受**;无 HOLD 的正常 change 全程零产出。非 Jarvis 场景的人工纠正本迭代不自动捕获(范围收缩,plan §12) |
82
83
  | ⑤ worker 处置 | 用 `orca orchestration worker-retain --dispatch <id>` 标记保留(**不可用 `worker-release`**——官方禁止因 escalation/question/idle 释放)。**语义澄清**:`worker-retain` 的官方定位是 "keep one supervised worker terminal live for debugging",**HOLD 保活属借用**该语义;保活效果与普通 settled 态的差异尚未实测(设计文档 §7.5 ⑪) |
83
84
  | ⑥ Jarvis | 写决策日志 + 早报「等你决定」段(问题/选项/Jarvis 倾向/依据/msg_id) |
84
85
 
@@ -49,7 +49,9 @@ Do NOT invoke for:
49
49
  ## Execution Flow(S1-S5 + ARCH 产品级架构设计)
50
50
 
51
51
  ### S1: 路径路由器
52
- **先做需求选择**(v0.15.0 多需求):读 `.team-flow/registry.yaml`,确定 `active_requirement`(多需求则询问操作哪个/新建)。再判断 7 种入口路径之一;检查 baseline.md / CONCEPTS.md(后者在 `docs/architecture/CONCEPTS.md`,根目录为旧位置)并注入;复利注入(INDEX.md 默认 top-5,见 `references/s1-path-router.md` 的窗口与排序口径)。**路由结果必须向用户显式确认**(路由是建议非决定)。详见 `references/s1-path-router.md`。
52
+ **先做需求选择**(v0.15.0 多需求):读 `.team-flow/registry.yaml`,确定 `active_requirement`(多需求则询问操作哪个/新建)。再判断 7 种入口路径之一;检查 baseline.md / CONCEPTS.md(后者在 `docs/architecture/CONCEPTS.md`,根目录为旧位置)并注入;**复利注入(P2-3 顶层调用,跑真命令而非只读声明)**:`tf solutions inject --phase prd --limit 5`(CLI 内含 P2-2 见习/红区门控;CLI 不可用才降级手动读 INDEX,降级不降门——见 `references/s1-path-router.md`)。**收益量化协议(P2-3)**:每次注入记录「条目数 + 后续阶段被引用/采纳条数」,采纳持续为 0 达 2 个样例需求 → 回退调用点(回退已预授权;冷启动 0 条目不计为收益 0,属语料未积累)。**路由结果必须向用户显式确认**(路由是建议非决定)。详见 `references/s1-path-router.md`。
53
+
54
+ **低风险降阈值(agent-governance P1-2 · A 档)**:同时满足 ① `arch_baseline` 已建档 ② 本次 scope 单一清晰(一句话可述、无跨模块疑点)③ 不涉红区(DP-A / Code Landing / publish)——则各阶段确认点**合并为一次推荐+确认**:S1 路由确认后直接进所选阶段,不为每个子步骤重复询问;含糊任一条 → 维持完整确认轮次。**边界不变**:下方 ⛔ 约束块的 `prd_draft` 强制等待确认(以 ⛔ 块身份引用、不锚行号——行号是位置不是身份)、红区永久挂起、DP-A 必经——A 档只减"清晰需求的重复确认轮次",不删强制点。
53
55
 
54
56
  **conventions 注入(v0.11 §33)**:
55
57
  - 读取 conventions 配置,注入为需求分析上下文
@@ -95,6 +97,8 @@ prd_draft → user_review → prototype_loop → prd_frozen → completed
95
97
 
96
98
  **场景判定(入口三态)**:全新项目 → 正向设计(首轮不可跳过);旧项目首轮(`arch_baseline` 缺失)→ 逆向重建 L0 骨架 → 渐进深化;已建档 + 迭代无结构性变更 → 跳过(**skip 必须物化**:写 `docs/architecture/iterations/vN/SKIPPED.md` 标记 + 理由,判定者=编排器+用户确认)。
97
99
 
100
+ **低风险轻审(agent-governance P1-2 · A 档)**:`arch_baseline` 齐 + 本次迭代无结构性变更(纯功能增量、不动聚合/限界上下文边界)→ 8 步设计可按**增量裁剪**执行(只重算受影响聚合,未触及段标注 `unchanged` 引用上版快照),评审走一次 product 视角 PASS 即过、不展开全量问询。**红线不降**:4A+DDD 六产物交付永不绕过;skip 仍须物化 + 用户确认;涉结构性变更(新聚合/BC 边界/跨模块 schema)→ 一律完整 8 步 + 重评审(判定含糊按完整走)。
101
+
98
102
  **执行**:调用 architecture-design skill 的 **product 模式**子代理(8 步设计:限界上下文/聚合注册表/指令事件/状态机/概念 ER/时序),产出 `docs/architecture/iterations/vN/architecture.md`(6 产物,provenance 标注)。
99
103
 
100
104
  **评审门**:产出经 architecture-reviewer product 视角(`review_mode: product`,A1-A6)评审,**PASS 才进 S3**。
@@ -108,7 +112,7 @@ prd_draft → user_review → prototype_loop → prd_frozen → completed
108
112
  4. 已存在(未拉取)→ 提示用户 git pull/检出对应服务
109
113
 
110
114
  ### S3: 计划阶段
111
- **入口一次性问定计划模式**(业务/一人公司),调用 `/ce-plan`(`pipeline_mode: orchestrator` + `plan_mode: business|solo`,跳过仪式开销、保留 repo research + change splitting + 依赖 DAG + 技术方向)产出 `requirement/vN/plan.md`。plan 只到产品级策略 + 高阶技术设计,**不含接口清单**(属各 change 的 spec-writer)。**S3 在 ARCH 之后**——基于架构定稿(聚合/服务/模块)做计划与拆分(2026-08-19 LT 调整)。反馈环路检查点:plan 是否暴露 PRD scope 问题(是→回退 S2)。详见 `references/s3-plan-pipeline.md`。完成条件:plan.md 产出 + S3 状态 = completed,**下一步进 S4**。
115
+ **复利注入(P2-3 顶层调用)**:调 ce-plan 前跑 `tf solutions inject --phase plan --limit 5`(phase 合法集以 `solutions-phases.mjs` 为准,S3 = `plan`;与 `s3-plan-pipeline.md` 同口径),把计划期相关经验(门禁踩坑/拆分教训)带入上下文;空结果/冷启动不阻断。**入口一次性问定计划模式**(业务/一人公司),调用 `/ce-plan`(`pipeline_mode: orchestrator` + `plan_mode: business|solo`,跳过仪式开销、保留 repo research + change splitting + 依赖 DAG + 技术方向)产出 `requirement/vN/plan.md`。**低风险轻审(P1-2 · A 档)**:PRD 已冻结且 scope 清晰(S1 低风险三条件成立)时,plan 产出后**一次确认**即进 S4,不逐节问询;ce-plan 反馈环路暴露疑点(scope 含糊/拆分不稳/架构缺口)→ 升级完整人审并回溯。plan 只到产品级策略 + 高阶技术设计,**不含接口清单**(属各 change 的 spec-writer)。**S3 在 ARCH 之后**——基于架构定稿(聚合/服务/模块)做计划与拆分(2026-08-19 LT 调整)。反馈环路检查点:plan 是否暴露 PRD scope 问题(是→回退 S2)。详见 `references/s3-plan-pipeline.md`。完成条件:plan.md 产出 + S3 状态 = completed,**下一步进 S4**。
112
116
 
113
117
  ### S4: 拆分验证与分发
114
118
 
@@ -52,6 +52,13 @@ S1 只做编排动作(需求选择、存在性检查、路径判断、阻塞
52
52
 
53
53
  读取 `docs/solutions/INDEX.md`(如存在),过滤 `phase = prd OR cross-phase` 且 domain 匹配的经验,取 **默认 top-5** 摘要注入为上下文约束。读取失败时跳过、不阻断(**无索引时 CLI 会输出一行 WARN 并返回空结果,那不是错误**)。
54
54
 
55
+ > **⚠ 手动读必须带与 CLI 相同的两道门(agent-governance P2-2,防 fallback 绕过)**:
56
+ > ① `flags` 列 = `probation`(见习条目)→ **跳过不注入**;② summary/domain 命中红区关键词
57
+ > (与 `RED_ZONE_RE` 全集一致:`DP-A` / `Code Landing` / `publish` / `发布闸` / `代码落地`)→ **跳过**
58
+ > (红区建议永不自动进上下文)。
59
+ > 两者都由 `tf solutions inject` 自动执行——**凡 CLI 可用的场合一律优先 CLI**,本手动路径只是
60
+ > CLI 不可用时的降级,降级不降门。
61
+
55
62
  > **窗口与排序须与 CLI 同口径(v0.57.0)**:排序为 **severity 降序 → 阶段匹配度(本阶段优先于通配的 cross-phase)→ date 降序**(三级键;旧的"仅 severity 降序"已被取代)。窗口默认 5,用 `tf solutions inject --phase <p> --limit <n>` 放宽——cross-phase 条目满载 5 条时,本阶段新增条目**永不可达**,故凡有 CLI 可用的场合优先用 CLI(`--all` 输出全部,但无上界,慎用)。同 `source` 的条目折叠为 1 条并标注条数。
56
63
 
57
64
  工作流模式复利(L2):S1 路由时额外注入历史 `workflow_pattern` top-3(confidence ≥ 0.5)。详见 state-model.md「工作流模式复利 L2」。
@@ -56,7 +56,8 @@ PRD草稿生成后:
56
56
  ### 2. 判断是否需要原型
57
57
 
58
58
  - 需要(涉及 UI/交互/页面)→ 进入原型循环
59
- - 不需要(纯后端/无 UI)→ **先走步骤 3.5 完整性评审**,再冻结,跳到步骤 5
59
+ - 不需要(纯后端/无 UI)→ **先走步骤 3.4 清晰度机械门 → 3.5 完整性评审**,再冻结,跳到步骤 5
60
+ (**3.4 不可绕过**——P0-1 fail-closed;无 UI 只跳原型循环,不跳任何评审/机械门)
60
61
 
61
62
  ### 3. 原型循环(编排层控制)
62
63
 
@@ -78,13 +79,26 @@ PRD草稿生成后:
78
79
 
79
80
  **人工介入 = 编排层阻塞确认**(非 subagent,因 subagent 不能 AskUserQuestion),呈现争议项 + 选项(接受现状 / 指定修正方向 / 升版 / 放弃原型)。
80
81
 
82
+ ### 3.4 PRD 清晰度机械检查(冻结前门禁,agent-governance P0-1)
83
+
84
+ 进入 3.5 完整性评审**之前**,编排层运行机械门(checker 先跑拦明显问题,LLM 评审随后):
85
+
86
+ ```
87
+ tf prd check-clarity <工作区根> # 自动定位 requirement/vN/prd.md
88
+ ```
89
+
90
+ - **末行 `STATUS: PASS | FAIL`(非零退出码 = FAIL),必须读取**:FAIL → 直接回 ce-brainstorm Phase 1.3/Phase 3 修订,**不派发** 3.5 的 prd-completeness-reviewer(机械门已 FAIL,省一轮 LLM 评审);PASS → 进入 3.5。
91
+ - 判据 = 弱词 8 类 / 必需段缺失 / §8.4 左列技术维度漂移(fail-closed,见 `scripts/guard/checks/prd-clarity.mjs` 头注)。
92
+ - **首版无豁免通道**:误报时改 PRD 文字,或走代码变更调 checker 词表(校准纪律在 checker 头注)。
93
+ - resume 断点恢复:本检查挂评审链路(3.4→3.5→4),不挂保存步骤——resume 重走评审链自然重跑,不检半成品。
94
+
81
95
  ### 3.5 PRD 完整性评审(冻结前门禁,v0.47)
82
96
 
83
97
  **orchestrated 路径下完整性评审由编排层在此派发**(standalone 路径由 ce-brainstorm Phase 3.5 内部派发,见 ce-brainstorm `references/prototype-loop.md` §3.5.5)。
84
98
 
85
99
  - 派发:按名派发插件 agent `prd-completeness-reviewer`(6 维,含 §8.4 信息齐备性与业务可读形态 D6),传入 `prd_path` + `concepts_path`(可选)+ `template_path`(默认**插件内置** `templates/prd.md`)+ **`spec_path`**(默认 `${CLAUDE_PLUGIN_ROOT}/skills/ce-brainstorm/references/prd-84-authoring-spec.md`,§8.4 规范唯一权威)+ `detail_ledger_path`(如有)。
86
100
  - 判定:PASS / PASS_WITH_WARNINGS → 进入步骤 4 冻结;**FAIL(Critical>0:D1/D2 缺失、D6 核心信息缺失、D6 悬空功能)→ 回 ce-brainstorm Phase 1.3/Phase 3 修订后重审**。D6 形态核验(G7)命中判 Important,不直接触发 FAIL,但须记录并交人工裁定。
87
- - **适用性**:需要原型(步骤 3 完成后)与不需要原型(纯后端无 UI,步骤 2 后)两条路径**均必须派发**——不因跳过原型循环而跳过完整性评审。
101
+ - **适用性**:需要原型(步骤 3 完成后)与不需要原型(纯后端无 UI,步骤 2 后)两条路径**均必须派发**——不因跳过原型循环而跳过完整性评审。**两路径的前置均为步骤 3.4(prd-clarity 机械门)**——3.4 FAIL 不派发本评审,直接回改。
88
102
 
89
103
  ### 4. 冻结
90
104
 
@@ -35,7 +35,7 @@ ce-plan 在 orchestrator pipeline 上下文中减少仪式开销,但**保留
35
35
 
36
36
  ## 复利
37
37
 
38
- - **注入**:读取 `docs/solutions/INDEX.md`,过滤 `phase = plan OR cross-phase`,取默认 top-5 摘要(窗口与排序口径见 `s1-path-router.md`;有 CLI 时优先 `tf solutions inject --phase plan --limit <n>`)
38
+ - **注入**:优先 `tf solutions inject --phase plan --limit 5`(CLI 内含见习/红区门控);CLI 不可用才降级手动读 `docs/solutions/INDEX.md`(过滤 `phase = plan OR cross-phase`,窗口与排序口径见 `s1-path-router.md`)——**手动降级不降门(P2-2)**:跳过 `flags=probation` 行与红区关键词行(`DP-A`/`Code Landing`/`publish`/`发布闸`/`代码落地`)
39
39
  - **捕获**:检测可复利时刻(技术方向决策、拆分权衡等)
40
40
 
41
41
  ## 反馈环路检查点
@@ -123,7 +123,7 @@ Config-aware routing: check `artifacts.order` and `artifacts.skip` from project
123
123
 
124
124
  ## Mode Detection
125
125
 
126
- If workflow is `auto`/`null`/unset: run `tf runtime infer <change-dir>`. 双通道输出(v0.64.0):`mode` ∈ **hotfix**(≤2 tasks/≤2 files) / **tweak**(≤4, config/doc) / **full**(更大;quick/lightweight 仅由显式前门写入)+ `suggested_path` ∈ direct|planned|null(arch/API/DB/聚合信号 → 建议 planned 而非 full,D1)。
126
+ If workflow is `auto`/`null`/unset: run `tf runtime infer <change-dir>`. 双通道输出(v0.64.0):`mode` ∈ **hotfix**(≤2 tasks/≤2 files) / **tweak**(≤4, config/doc) / **full**(更大;quick/lightweight 仅由显式前门写入)+ `suggested_path` ∈ direct|planned|null(arch/API/DB/聚合信号 → 建议 planned 而非 full,D1)。**P1-1 双信号**:`clarity` ∈ pass|fail|null + `risk` ∈ low|medium|high|null——`clarity=fail` 或 `risk=high` 时路由推荐倾向**完整人审路径**(建议级;硬阻断由 guard 的 `prd-clarity`/`history-risk` 维度承担,两者分工不重叠)。
127
127
 
128
128
  **持久化改为「建议+询问」(P4 落地)**:有 TTY → 回显 `mode` + `suggested_path` 建议,AskUserQuestion 确认后 `tf state set <dir> workflow <mode>`;无 TTY → 按建议直接落盘并在输出中记 `infer_source=suggested`(B-12,e2e/jarvis 不挂起)。**`suggested_path` 只进前门选择提示,绝不写入 `state.workflow`。**
129
129
 
package/templates/prd.md CHANGED
@@ -320,6 +320,12 @@
320
320
  > **语汇**:正文主干用 §6 术语字典的**业务名**;类名 / 方法名 / 表名 / 行号不得出现,确需时以括注附于业务名后。
321
321
  > **精确**:禁用弱词(较快 / 友好 / 支持 / 适当 / 等 / 尽可能 / 必要时)——模糊表述会被下游自行解释,产生静默缺陷。
322
322
  > **完整性**:11 维 / 7 维清单**降为内部校验清单**,撰写前用它核对信息齐备,撰写时按业务认知顺序重组进正文,**不得**把清单写进正文;不适用维度在 `detail-ledger.md` 标 `NA + 理由`。
323
+ >
324
+ > **⚠ 撰写指引剥离规则(prd-writer 实例化时 MUST 遵守,agent-governance P0-1)**:本模板中
325
+ > 所有 `>` 撰写指引 blockquote(含上方「语汇/精确/完整性」与「可解析性」等指引段)是给撰写者的
326
+ > 元指令,**实例化 PRD 时必须整体剥离,不得写入 `requirement/vN/prd.md` 正文**——否则指引中的
327
+ > 弱词示例(本行自带「较快/友好/支持」等)会直接触发冻结前 `tf prd check-clarity` 机械门 FAIL,
328
+ > 且首版无豁免通道 = 死循环。`{…}` 占位符同样只在模板中存在。
323
329
 
324
330
  ### 8.5 非功能性需求说明
325
331
 
@@ -417,7 +423,9 @@
417
423
  > 本表只列名目与结果,**不重复列出条款正文**——同一规则两处维护必然漂移。
418
424
  >
419
425
  > **两处声明**:① **自查 ≠ 规格正文**——本节是**撰写者自检清单**,不构成对业务方的规格条款,
420
- > 判定权仍在业务评审;② **非脚本门禁**——不得将本节接入机械门禁脚本。
426
+ > 判定权仍在业务评审;② **非脚本门禁**——不得将本节(可读性自查节)接入机械门禁脚本
427
+ > (勘误 2026-09-25:弱词检测已独立落地为 `prd-clarity.mjs` 机械门,与本声明不冲突——
428
+ > 该门查 §4 弱词/必需段/§8.4 漂移,不查本可读性自查节)。
421
429
 
422
430
  | 编号 | 自查项(详见规范文件 §8) | 结果 | 备注 |
423
431
  |---|---|---|---|