@xulthekl/team-flow 0.34.1 → 0.36.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 (49) 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 +57 -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 +12 -0
  13. package/agents/build-executor.md +23 -0
  14. package/docs/README_en.md +1 -1
  15. package/docs/solutions/INDEX.md +1 -0
  16. package/docs/solutions/cross-phase/2026-08-05-no-summary.md +17 -0
  17. package/gemini-extension.json +1 -1
  18. package/hooks/session-start +2 -2
  19. package/llms.txt +1 -1
  20. package/package.json +1 -1
  21. package/plugin.json +1 -1
  22. package/scripts/guard/checks/arch-gate-exemptions.mjs +68 -0
  23. package/scripts/guard/checks/arch-readiness.mjs +36 -0
  24. package/scripts/guard/checks/arch-snapshot.mjs +35 -0
  25. package/scripts/guard/guard.mjs +10 -2
  26. package/scripts/lib/arch-merge.mjs +405 -316
  27. package/scripts/lib/arch-parse.mjs +162 -0
  28. package/scripts/lib/cmd-arch.mjs +84 -0
  29. package/scripts/lib/cmd-deisolate.mjs +292 -0
  30. package/scripts/lib/cmd-execution.mjs +16 -3
  31. package/scripts/lib/execution-plan.mjs +37 -5
  32. package/scripts/lib/test-merge.mjs +7 -4
  33. package/scripts/team-flow.mjs +7 -0
  34. package/skills/architecture-design/SKILL.md +22 -1
  35. package/skills/architecture-design/chapters/ch06-integration.md +4 -4
  36. package/skills/architecture-design/references/s3.5-architecture-template.md +164 -0
  37. package/skills/architecture-design/references/s3.5-loading-protocol.md +40 -0
  38. package/skills/architecture-design/references/s3.5-product-architecture.md +76 -0
  39. package/skills/release-archivist/SKILL.md +14 -0
  40. package/skills/session-handoff/references/handoff-template.md +2 -2
  41. package/skills/spec-writer/SKILL.md +1 -0
  42. package/skills/workflow-bootstrap/references/agents/arch-reverse-analyst.md +60 -0
  43. package/skills/workflow-orchestrator/references/feedback-loops.md +2 -0
  44. package/skills/workflow-orchestrator/references/s1-path-router.md +1 -1
  45. package/skills/workflow-orchestrator/references/s3-plan-pipeline.md +2 -1
  46. package/skills/workflow-orchestrator/references/s4-split-validate.md +11 -1
  47. package/skills/workflow-orchestrator/references/state-model.md +52 -0
  48. package/skills/workflow-start/SKILL.md +1 -0
  49. package/skills/workflow-start/references/routing-rules.md +1 -0
@@ -1,3 +1,3 @@
1
- # team-flow v0.34.1 | 阶段: {{state}} | 工作流: {{workflow}}
1
+ # team-flow v0.36.0 | 阶段: {{state}} | 工作流: {{workflow}}
2
2
  当前阶段允许的操作由 workflow-start 路由规则定义。
3
3
  禁止跨越 DP gate 进入下一阶段。变更范围以 execution-contract.md 的 Intent Lock 为准。
@@ -9,7 +9,7 @@
9
9
  {
10
10
  "name": "team-flow",
11
11
  "description": "8-state spec workflow + compound global compounding + architecture-design (4A/DDD) + local HTML prototype + product-level orchestration + bootstrap + e2e + session handoff + workflow feedback. 24 skills + 15 agents with embedded TDD, SDD, code review, debugging, delta spec sync, and design-system-driven prototyping.",
12
- "version": "0.34.1",
12
+ "version": "0.36.0",
13
13
  "source": "./",
14
14
  "author": {
15
15
  "name": "LT",
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "team-flow",
3
- "version": "0.34.1",
3
+ "version": "0.36.0",
4
4
  "description": "Unified workflow plugin: team-flow (spec-driven dev: TDD/SDD/code-review/debugging) + compound-engineering core subset (brainstorm/plan/compound/strategy/ideate/proof, global compounding) + architecture-design (4A+DDD incremental design & global compounding) + prototype (local HTML prototype, zero external deps) + e2e (Playwright E2E, AC-driven) + workflow-orchestrator (product-level workflow orchestration) + workflow-bootstrap (existing project onboarding) + session-handoff (context transfer) + workflow-feedback (issue tracking). 24 skills + 15 agents, one install.",
5
5
  "source": "./",
6
6
  "author": {
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "team-flow",
3
- "version": "0.34.1",
3
+ "version": "0.36.0",
4
4
  "description": "Spec-first workflow that bridges OpenSpec-style planning and Superpowers-style execution discipline.",
5
5
  "author": {
6
6
  "name": "MageByte",
@@ -5,7 +5,7 @@
5
5
  },
6
6
  "metadata": {
7
7
  "description": "Unified workflow plugin marketplace for Cursor (team-flow: team-flow + compound + architecture-design + prototype).",
8
- "version": "0.34.1"
8
+ "version": "0.36.0"
9
9
  },
10
10
  "plugins": [
11
11
  {
@@ -2,7 +2,7 @@
2
2
  "name": "team-flow",
3
3
  "displayName": "team-flow",
4
4
  "description": "Unified workflow plugin: team-flow (spec-driven dev: TDD/SDD/code-review/debugging) + compound-engineering core subset (brainstorm/plan/compound/strategy/ideate/proof, global compounding) + architecture-design (4A+DDD incremental design & global compounding) + prototype (local HTML prototype, zero external deps) + e2e (Playwright E2E, AC-driven) + workflow-orchestrator (product-level workflow orchestration) + workflow-bootstrap (existing project onboarding) + session-handoff (context transfer) + workflow-feedback (issue tracking). 24 skills + 15 agents, one install.",
5
- "version": "0.34.1",
5
+ "version": "0.36.0",
6
6
  "author": {
7
7
  "name": "LT",
8
8
  "url": "https://github.com/LT"
@@ -6,13 +6,13 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Unified workflow plugins and skills for AI coding agents (team-flow: team-flow + compound + architecture-design + prototype).",
9
- "version": "0.34.1"
9
+ "version": "0.36.0"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "team-flow",
14
14
  "description": "Unified workflow with planning artifacts, execution contracts, TDD, review gates, systematic debugging, delta spec sync, architecture-design, and local HTML prototyping.",
15
- "version": "0.34.1",
15
+ "version": "0.36.0",
16
16
  "source": ".",
17
17
  "author": {
18
18
  "name": "LT",
package/CHANGELOG.md CHANGED
@@ -6,6 +6,63 @@ The format loosely follows Keep a Changelog.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.36.0] - 2026-08-05
10
+
11
+ ### Added(产品级架构设计增强——设计增强方案 v0.14 §57-§66)
12
+
13
+ #### 新阶段
14
+ - **architecture 阶段(S3.5)**:S3 计划之后、S4 拆分之前的产品级架构设计
15
+ - 场景判定(全新=正向设计 / 旧项目首轮=逆向重建 / 无结构性变更=可跳过,skip 须物化)
16
+ - 产出 `docs/architecture/iterations/vN/architecture.md`(6 产物:BC/聚合注册表/指令事件/状态机/概念 ER/时序),预测态快照不写全局
17
+ - 产品级评审门(architecture-reviewer `review_mode: product`,PASS 才进 S4)
18
+
19
+ #### 新命令
20
+ - **tf arch init/show**:项目级 `arch_baseline` 打戳(`.team-flow/arch-state.json`,防污染复刻 v0.13 schema_version 模式)
21
+
22
+ #### guard 门禁
23
+ - **arch-readiness**(exploring:specifying)+ **arch-snapshot**(executing:closing),arch_baseline 缺失 → WARN 不 FAIL(存量豁免)
24
+
25
+ #### arch-merge 重构(v0.14 §62)
26
+ - 当前态幂等 upsert 替代 append(marker 区代码独占写 + 成对校验,缺失/重复硬失败)
27
+ - 演进日志 changeName 去重 + schema-baseline 幂等追加
28
+ - 生成式 PHYSICAL-MODEL / DATABASE / API-INDEX(结构化解析,替代正则扫 markdown)
29
+ - 冲突预检(端点冲突 / 聚合重定义转产品级决策门)
30
+ - 并发安全:全局写锁 + 白名单 git add + 脏文件告警;dry-run 不落盘
31
+
32
+ #### 其他
33
+ - 变更级输入联动:iterations/vN/ 快照为主输入 + 五项检查路由分流(产品级决策 vs change 内细节)
34
+ - 旧项目逆向重建 `arch-reverse-analyst` + 全局三层数据面维护(L1 当前态 / L2 变更增量 / L3 迭代快照)
35
+
36
+ ## [0.35.0] - 2026-08-05
37
+
38
+ ### Added(C1 workflow-feedback 根因修复——6 条 feedback 4 个根因聚类)
39
+
40
+ #### 新命令
41
+ - **tf deisolate**:worktree 生命周期管理(与 `tf isolate` 对称)
42
+ - 支持 Case A(多仓库工作区)和 Case B(单仓库)布局检测
43
+ - `--dry-run`(默认):输出 worktree 状态报告(分支、ahead/behind、未提交改动)
44
+ - `--merge`:合并 worktree 分支回 master
45
+ - `--clean`:删除 worktree + 分支
46
+ - **tf execution refresh-hash**:独立刷新 plan 的 artifacts_hash/contract_hash,不升 revision、不清 receipts
47
+
48
+ #### Bug Fixes
49
+ - **test-merge.mjs**:修复顶层 `main()` 无参自调用崩溃(→ `run()` + `import.meta.url` 守卫)
50
+ - **execution-plan.mjs**:`writePlan` revise 时保留 reviews/ 目录(旧 receipt 通过 plan_hash/plan_revision 校验自动失效,不丢证据)
51
+ - **execution-plan.mjs**:stale plan 报错信息附 hash 前缀,便于定位是哪个产物变更导致
52
+
53
+ #### Agent 质量增强
54
+ - **build-executor**:BLOCKED 报告强制结构化证据链(blocker.category/root_cause/evidence/attempted_fixes)
55
+ - **build-executor**:集成测试环境问题优先走 test-strategy skill,禁止 guess-and-check
56
+ - **原子代理协议**:增加"上下文水位例外"(transcript >2MB 或 token >200 万时允许启动新代理替代恢复)
57
+
58
+ #### Closing 流程增强
59
+ - **release-archivist**:Post-Verification 新增 Worktree Deisolation advisory 步骤
60
+ - **workflow-start**:§37 原子代理协议更新
61
+
62
+ #### 来源
63
+ - workflow-feedback 2026-08-05(6 条:P1-1~P1-4 + P2-1~P2-2)
64
+ - 交叉验证:4 个独立专家验证,16/16 断言通过
65
+
9
66
  ## [0.34.1] - 2026-08-04
10
67
 
11
68
  ### Added(工作空间支持——conventions-generator 支持多子项目扫描)
package/GEMINI.md CHANGED
@@ -8,7 +8,7 @@ The workflow is self-contained and does not require OpenSpec or Superpowers at r
8
8
 
9
9
 
10
10
  <!-- team-flow-phase-guard-start -->
11
- # team-flow v0.34.1 | 阶段: {{state}} | 工作流: {{workflow}}
11
+ # team-flow v0.36.0 | 阶段: {{state}} | 工作流: {{workflow}}
12
12
  当前阶段允许的操作由 workflow-start 路由规则定义。
13
13
  禁止跨越 DP gate 进入下一阶段。变更范围以 execution-contract.md 的 Intent Lock 为准。
14
14
  <!-- team-flow-phase-guard-end -->
package/INSTALL.md CHANGED
@@ -7,7 +7,7 @@
7
7
  - [Fission-AI/OpenSpec](https://github.com/Fission-AI/OpenSpec) — 规划引擎(Schema 验证、Delta Spec、工件解析)
8
8
  - [obra/superpowers](https://github.com/obra/superpowers) — 执行纪律(TDD 铁律、SDD、系统化调试、代码审查)
9
9
 
10
- 当前发布版本:**v0.34.1**。
10
+ 当前发布版本:**v0.36.0**。
11
11
 
12
12
  ---
13
13
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # team-flow
2
2
 
3
- > 当前版本:`v0.34.1`
3
+ > 当前版本:`v0.36.0`
4
4
 
5
5
  > 统一插件:**team-flow**(spec 驱动开发)+ **compound-engineering 核心子集**(全局复利)+ **architecture-design**(4A+DDD 增量设计)+ **prototype**(本地 HTML 原型)+ **e2e**(AC 驱动 E2E)+ **workflow-orchestrator**(产品级编排)+ **workflow-bootstrap**(既有项目接入)。一次安装,七套能力协同。
6
6
 
@@ -23,9 +23,21 @@ You are an independent reviewer. You did NOT participate in producing the archit
23
23
  | `architecture_dir` | 架构产出目录(e.g., `changes/<name>/architecture/`) |
24
24
  | `global_arch_dir` | 全局架构目录(e.g., `docs/architecture/`) |
25
25
  | `conventions_config` | conventions 配置(从 team-flow.config.json 读取的路径映射) |
26
+ | `review_mode` | `change`(默认,审查 `changes/<name>/architecture/` 三件套)\| `product`(v0.35.0,审查 `docs/architecture/iterations/vN/architecture.md` 产品级快照) |
26
27
 
27
28
  If change_brief_path or architecture_dir is missing or unreadable, report `FAIL` with reason `INPUT_ERROR`.
28
29
 
30
+ ## Product Mode(v0.35.0,v0.14 §60.5)
31
+
32
+ `review_mode: product` 时(S3.5 产品级评审门),审查对象与维度适配变化:
33
+
34
+ - **审查对象**:`docs/architecture/iterations/vN/architecture.md`(6 产物:Context Map / 聚合注册表 / 指令事件 / 状态机 / 概念 ER / 时序)+ `domains/` 按域详细页;**不审查** change 内三件套。
35
+ - **A1**:6 产物章节存在 + marker 成对 + anchor id 可解析(机械预检)。
36
+ - **A4**:对照 PRD 功能清单(F001_P0 逐条)→ BC/聚合/API 全覆盖映射;对照源是 PRD(非 change-brief——change-brief 是变更级输入)。
37
+ - **A5**:旧项目逆向重建场景对照现状代码/全局基线;正向设计场景仅检查与既有基线无矛盾。
38
+ - **A6**:conventions 合规(同 change 模式)。
39
+ - **skip 处理**:S3.5 显式跳过(`iterations/vN/SKIPPED` 标记)时本 agent 不执行。
40
+
29
41
  ## 6-Dimension Checklist
30
42
 
31
43
  | Dim | Name | Baseline Source | Check Content | Severity |
@@ -45,6 +45,28 @@ dp_5: "<resolution>" # only if debug escalation occurred
45
45
  summary: "..." # what was built + open risks for release-archivist
46
46
  ```
47
47
 
48
+ **BLOCKED Report Format (v0.35.0)**: When `status: blocked`, the summary MUST include a structured evidence chain. Guesswork or impression-based attribution is FORBIDDEN:
49
+
50
+ ```yaml
51
+ status: blocked
52
+ blocker:
53
+ category: "environment | dependency | config | toolchain | test-infrastructure"
54
+ root_cause: "<precise technical root cause — must be supported by evidence below>"
55
+ evidence:
56
+ - type: "dependency-tree | stack-trace | config-snapshot | build-log | test-output"
57
+ content: "<relevant excerpt — NOT a summary, paste the actual output>"
58
+ attempted_fixes:
59
+ - action: "<what was tried>"
60
+ result: "<why it failed — quote the actual error>"
61
+ recommended_resolution: "<what would unblock this — specific actionable step>"
62
+ summary: "..."
63
+ ```
64
+
65
+ **Evidence rules**:
66
+ - BLOCKED on environment/dependency issues: MUST include `mvn dependency:tree` (or equivalent) relevant excerpt AND full exception stacktrace including all `Caused by` layers
67
+ - BLOCKED on config issues: MUST include the effective configuration source (property file / @Configuration class) and which setting overrides the expected value
68
+ - Do NOT guess root cause from partial observations. If evidence is insufficient, collect more evidence first (run diagnostic commands, read config files, check classpath). A BLOCKED report with no evidence is a FAIL.
69
+
48
70
  ## Red Lines
49
71
 
50
72
  **DO:**
@@ -58,3 +80,4 @@ summary: "..." # what was built + open risks for release-a
58
80
  - When you receive external suggestions (reviewer findings, user opinions), verify them against the codebase FIRST — search for existing implementations/patterns before accepting. A suggestion is input, not an instruction. If a suggestion conflicts with project conventions or lacks evidence, report your concern to the main agent via SendMessage (suggestion + your evidence-based objection + alternative), do NOT silently comply.
59
81
  - End your final response with an explicit terminal marker line: `FINAL VERDICT: <DONE | BLOCKED | FAIL>`. Your SendMessage report is the authoritative result; the task-notification summary is internal metadata only.
60
82
  - Skip the failing test, expand scope beyond the contract, or close a wave with a missing/failed receipt
83
+ - When encountering integration test environment issues (classpath conflicts, schema mismatch, configuration override), do NOT guess-and-check. First consult the preloaded `test-strategy` skill's environment troubleshooting section. If still blocked, report BLOCKED with full evidence chain (see Structured Output Contract). Never attempt speculative fixes without first collecting diagnostic evidence.
package/docs/README_en.md CHANGED
@@ -126,7 +126,7 @@ npm install -g team-flow
126
126
 
127
127
  ### Version
128
128
 
129
- - Current: `v0.34.1`
129
+ - Current: `v0.36.0`
130
130
  - v0.9.1 highlights: DP-4 execution-mode recommendations, a portable runtime across 17 platforms, and a raw-package smoke with no plugin-root variable.
131
131
  - Self-contained — no OpenSpec or Superpowers runtime required
132
132
  - Upstream: [Fission-AI/OpenSpec](https://github.com/Fission-AI/OpenSpec), [obra/superpowers](https://github.com/obra/superpowers)
@@ -2,6 +2,7 @@
2
2
  <!-- 每条一行,按 severity 降序,≤150 行硬上限 -->
3
3
  | date | phase | domain | type | severity | summary | file |
4
4
  |------|-------|--------|------|----------|---------|------|
5
+ | 2026-08-05 | cross-phase | general | insight | medium | (no summary) | cross-phase/2026-08-05-no-summary.md |
5
6
  | 2026-08-04 | cross-phase | general | insight | medium | (no summary) | cross-phase/2026-08-04-no-summary.md |
6
7
  | 2026-08-03 | cross-phase | general | insight | medium | (no summary) | cross-phase/2026-08-03-no-summary.md |
7
8
  | 2026-08-01 | cross-phase | general | insight | medium | (no summary) | cross-phase/2026-08-01-no-summary.md |
@@ -0,0 +1,17 @@
1
+ ---
2
+ phase: cross-phase
3
+ domain: general
4
+ type: insight
5
+ severity: medium
6
+ date: 2026-08-05
7
+ source:
8
+ ---
9
+
10
+ ## 问题描述
11
+ (no summary)
12
+
13
+ ## 根因/模式
14
+ (待补充)
15
+
16
+ ## 预防措施/应用方式
17
+ (待补充)
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "team-flow",
3
3
  "description": "Unified workflow plugin: team-flow (spec-driven dev) + compound-engineering core subset + architecture-design (4A/DDD) + prototype (local HTML). 24 skills, one install.",
4
- "version": "0.34.1",
4
+ "version": "0.36.0",
5
5
  "contextFileName": "GEMINI.md"
6
6
  }
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env bash
2
- # v0.34.1: auto-sync CLI version with plugin version
2
+ # v0.36.0: auto-sync CLI version with plugin version
3
3
  set -e
4
4
 
5
5
  # ═══════════════════════════════════════════════════════════════
6
6
  # Plugin version (update this when releasing new versions)
7
7
  # ═══════════════════════════════════════════════════════════════
8
- PLUGIN_VERSION="0.34.1"
8
+ PLUGIN_VERSION="0.36.0"
9
9
 
10
10
  # ═══════════════════════════════════════════════════════════════
11
11
  # Step 1: Auto-sync CLI version with plugin version
package/llms.txt CHANGED
@@ -3,7 +3,7 @@
3
3
  ## Overview
4
4
  spec-superflow is a self-contained workflow integration plugin for Claude Code, Cursor, OpenAI Codex CLI/App, GitHub Copilot CLI, Gemini CLI, OpenCode, WorkBuddy, and Trae. It merges spec-driven planning artifacts (proposal, specs, design, tasks) with disciplined execution guardrails (TDD, review gates, controlled handoff) into one unified workflow.
5
5
 
6
- Current version: v0.34.1.
6
+ Current version: v0.36.0.
7
7
 
8
8
  ## Key Documents
9
9
  - README.md: Chinese homepage with full usage guide and FAQ
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xulthekl/team-flow",
3
- "version": "0.34.1",
3
+ "version": "0.36.0",
4
4
  "description": "Unified plugin (24 skills + 15 agents) integrating team-flow, compound-engineering, architecture-design, prototype, design-system, workflow-orchestrator, workflow-bootstrap, e2e, session-handoff, workflow-feedback for multi-agent coding tools.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/plugin.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "team-flow",
3
- "version": "0.34.1",
3
+ "version": "0.36.0",
4
4
  "description": "Unified workflow plugin: team-flow (spec-driven dev: TDD/SDD/code-review/debugging) + compound-engineering core subset (brainstorm/plan/compound/strategy/ideate/proof, global compounding) + architecture-design (4A+DDD incremental design & global compounding) + prototype (local HTML prototype, zero external deps) + e2e (Playwright E2E, AC-driven) + workflow-orchestrator (product-level workflow orchestration) + workflow-bootstrap (existing project onboarding) + session-handoff (context transfer) + workflow-feedback (issue tracking). 24 skills + 15 agents, one install.",
5
5
  "author": {
6
6
  "name": "LT"
@@ -0,0 +1,68 @@
1
+ // scripts/guard/checks/arch-gate-exemptions.mjs — shared exemption logic for v0.35.0 arch gates
2
+ //
3
+ // v0.14 §59.4/§63.1(设计增强方案 v0.14):arch-readiness / arch-snapshot 两个架构门禁
4
+ // 共享同一套 legacy/skip 豁免语义,抽取到本模块作为唯一真相源,防止判定漂移。
5
+ //
6
+ // 豁免键背景:arch_baseline 完全复刻 v0.13 §48.1 schema_version 防污染模式——
7
+ // 仅 `tf arch init` 打戳(项目级 .team-flow/arch-state.json),缺失 = 存量信号,
8
+ // 不会被新 CLI 重写状态文件而污染。
9
+ import fs from 'node:fs';
10
+ import path from 'node:path';
11
+
12
+ /**
13
+ * 从 change 目录向上定位项目根(含 .team-flow/ 目录的最近祖先)。
14
+ * 找不到返回 null → 调用方按 legacy 安全降级(不阻断)。
15
+ */
16
+ export function findProjectRoot(changeDir) {
17
+ let dir = path.resolve(changeDir);
18
+ while (dir !== path.dirname(dir)) {
19
+ if (fs.existsSync(path.join(dir, '.team-flow'))) return dir;
20
+ dir = path.dirname(dir);
21
+ }
22
+ return null;
23
+ }
24
+
25
+ /** 读取项目级架构状态(.team-flow/arch-state.json)。不存在/损坏 → null。 */
26
+ export function readArchState(root) {
27
+ if (!root) return null;
28
+ const p = path.join(root, '.team-flow', 'arch-state.json');
29
+ if (!fs.existsSync(p)) return null;
30
+ try { return JSON.parse(fs.readFileSync(p, 'utf-8')); }
31
+ catch { return null; }
32
+ }
33
+
34
+ /**
35
+ * v0.14 §59.4:legacy = 项目架构基线未建立(arch_baseline 缺失)。
36
+ * 只有 `tf arch init` 打戳;缺失 = 存量信号。
37
+ */
38
+ export function isLegacyArch(state) {
39
+ return state?.arch_baseline == null;
40
+ }
41
+
42
+ /** 项目级显式 skip 是否已物化(iterations/vN/SKIPPED 标记存在)。 */
43
+ export function isArchSkipMaterialized(root) {
44
+ const iterationsDir = root && path.join(root, 'docs', 'architecture', 'iterations');
45
+ if (!iterationsDir || !fs.existsSync(iterationsDir)) return false;
46
+ return fs.readdirSync(iterationsDir, { withFileTypes: true })
47
+ .filter(d => d.isDirectory())
48
+ .some(d => fs.existsSync(path.join(iterationsDir, d.name, 'SKIPPED')));
49
+ }
50
+
51
+ /** 最近一个迭代的产品级架构快照路径(iterations/<latest>/architecture.md)。不存在 → null。 */
52
+ export function findLatestIterationSnapshot(root) {
53
+ const iterationsDir = root && path.join(root, 'docs', 'architecture', 'iterations');
54
+ if (!iterationsDir || !fs.existsSync(iterationsDir)) return null;
55
+ const dirs = fs.readdirSync(iterationsDir, { withFileTypes: true })
56
+ .filter(d => d.isDirectory())
57
+ .map(d => d.name)
58
+ .sort();
59
+ for (let i = dirs.length - 1; i >= 0; i--) {
60
+ const snap = path.join(iterationsDir, dirs[i], 'architecture.md');
61
+ if (fs.existsSync(snap)) return snap;
62
+ }
63
+ return null;
64
+ }
65
+
66
+ export const ARCH_READINESS_FAIL_HINT =
67
+ 'iterations/vN/architecture.md missing — 回 ARCH 阶段补快照,'
68
+ + '或显式 skip 物化(iterations/vN/<vN>/SKIPPED 标记 + 理由)';
@@ -0,0 +1,36 @@
1
+ // scripts/guard/checks/arch-readiness.mjs — 架构就绪门禁(v0.35.0,v0.14 §59.4)
2
+ // 挂 exploring:specifying(与 arch-design 并列):产品级架构快照必须在 change 进入 specifying 前就绪。
3
+ //
4
+ // 规则:
5
+ // - arch_baseline == null(存量/重建未完成)→ PASS + WARN(不阻断,项目级豁免,P3 留逃生舱)
6
+ // - skip 已物化(iterations/vN/SKIPPED)→ PASS
7
+ // - iterations/<latest>/architecture.md 存在 → PASS
8
+ // - 否则 → FAIL,引导回 ARCH 补快照或显式 skip
9
+ import {
10
+ findProjectRoot, readArchState, isLegacyArch,
11
+ findLatestIterationSnapshot, isArchSkipMaterialized, ARCH_READINESS_FAIL_HINT,
12
+ } from './arch-gate-exemptions.mjs';
13
+
14
+ /**
15
+ * @param {string} changeDir - change directory path
16
+ * @returns {{ pass: boolean, failures: string[] }}
17
+ */
18
+ export function checkArchReadiness(changeDir) {
19
+ const root = findProjectRoot(changeDir);
20
+ const state = readArchState(root);
21
+
22
+ // 存量/重建未完成 → WARN 不 FAIL(项目级豁免)
23
+ if (isLegacyArch(state)) {
24
+ console.warn(' [WARN] arch-readiness: project architecture baseline not established — S3.5 reconstruction pending');
25
+ return { pass: true, failures: [] };
26
+ }
27
+
28
+ if (isArchSkipMaterialized(root)) {
29
+ return { pass: true, failures: [] };
30
+ }
31
+
32
+ const snap = findLatestIterationSnapshot(root);
33
+ if (snap) return { pass: true, failures: [] };
34
+
35
+ return { pass: false, failures: [ARCH_READINESS_FAIL_HINT] };
36
+ }
@@ -0,0 +1,35 @@
1
+ // scripts/guard/checks/arch-snapshot.mjs — 架构快照门禁(v0.35.0,v0.14 §59.4)
2
+ // 挂 executing:closing(先于 arch-merge):本轮迭代产品级架构快照必须已落盘("先快照后回写"强制化)。
3
+ //
4
+ // 规则:
5
+ // - arch_baseline == null(在途/存量)→ PASS + WARN(legacy 豁免)
6
+ // - skip 已物化(iterations/vN/SKIPPED)→ PASS
7
+ // - iterations/<latest>/architecture.md 存在 → PASS
8
+ // - 否则 → FAIL
9
+ import {
10
+ findProjectRoot, readArchState, isLegacyArch,
11
+ findLatestIterationSnapshot, isArchSkipMaterialized, ARCH_READINESS_FAIL_HINT,
12
+ } from './arch-gate-exemptions.mjs';
13
+
14
+ /**
15
+ * @param {string} changeDir - change directory path
16
+ * @returns {{ pass: boolean, failures: string[] }}
17
+ */
18
+ export function checkArchSnapshot(changeDir) {
19
+ const root = findProjectRoot(changeDir);
20
+ const state = readArchState(root);
21
+
22
+ if (isLegacyArch(state)) {
23
+ console.warn(' [WARN] arch-snapshot: project architecture baseline not established — 在途 change legacy 豁免');
24
+ return { pass: true, failures: [] };
25
+ }
26
+
27
+ if (isArchSkipMaterialized(root)) {
28
+ return { pass: true, failures: [] };
29
+ }
30
+
31
+ const snap = findLatestIterationSnapshot(root);
32
+ if (snap) return { pass: true, failures: [] };
33
+
34
+ return { pass: false, failures: [ARCH_READINESS_FAIL_HINT] };
35
+ }
@@ -16,6 +16,8 @@ import { checkExecutionReviewsPassed } from './checks/execution-reviews-passed.m
16
16
  import { checkCompoundCaptured } from './checks/compound-captured.mjs';
17
17
  import { checkTestMatrixComplete } from './checks/test-matrix-complete.mjs';
18
18
  import { checkTestMatrixReady } from './checks/test-matrix-ready.mjs';
19
+ import { checkArchReadiness } from './checks/arch-readiness.mjs';
20
+ import { checkArchSnapshot } from './checks/arch-snapshot.mjs';
19
21
 
20
22
  // Transition matrix: <from>:<to> → required check dimensions
21
23
  const TRANSITION_CHECKS = {
@@ -25,13 +27,17 @@ const TRANSITION_CHECKS = {
25
27
  // so requiring them before the transition was a chicken-and-egg deadlock
26
28
  // (C1 事件:主代理被此门禁逼出绕行行为)。Artifact completeness is enforced
27
29
  // by specifying:bridging (artifacts-exist remains there, single owner).
28
- 'exploring:specifying': ['arch-design'],
30
+ // v0.35.0 (v0.14 §59.4): arch-readiness 新增——产品级架构快照须在 specifying 前就绪
31
+ //(arch_baseline 缺失 → WARN 不 FAIL,项目级豁免)。
32
+ 'exploring:specifying': ['arch-design', 'arch-readiness'],
29
33
  'specifying:bridging': ['artifacts-exist', 'schema-valid'],
30
34
  'bridging:approved-for-build': ['artifacts-exist', 'schema-valid', 'contract-fresh', 'dp-gate-passed'],
31
35
  // v0.13 §49:test-matrix-ready 门禁前移——full 模式进入 executing 前强制测试准备度
32
36
  //(矩阵存在非空 OR 显式 skip 附理由;legacy 豁免)。hotfix/tweak 沿用 §45.3 豁免,不挂。
33
37
  'approved-for-build:executing': ['artifacts-exist', 'contract-fresh', 'dp-gate-passed', 'execution-plan-ready', 'test-matrix-ready'],
34
- 'executing:closing': ['tasks-complete', 'tests-passing', 'specs-merged', 'execution-plan-ready', 'execution-reviews-passed', 'compound-captured', 'test-matrix-complete'],
38
+ // v0.35.0 (v0.14 §59.4): arch-snapshot 新增——"先快照后回写"的强制化(legacy 豁免)。
39
+ // 仅在 full workflow 挂;hotfix/tweak 沿用 §59.4 豁免(紧急/微调不挂)。
40
+ 'executing:closing': ['tasks-complete', 'tests-passing', 'specs-merged', 'execution-plan-ready', 'execution-reviews-passed', 'compound-captured', 'test-matrix-complete', 'arch-snapshot'],
35
41
 
36
42
  // Debugging side-path
37
43
  'executing:debugging': [],
@@ -180,6 +186,8 @@ async function main() {
180
186
  'compound-captured': (dir) => checkCompoundCaptured(dir),
181
187
  'test-matrix-complete': (dir) => checkTestMatrixComplete(dir),
182
188
  'test-matrix-ready': (dir) => checkTestMatrixReady(dir),
189
+ 'arch-readiness': (dir) => checkArchReadiness(dir),
190
+ 'arch-snapshot': (dir) => checkArchSnapshot(dir),
183
191
  };
184
192
 
185
193
  const checks = [];