Files
ai4se-harness-suite/team-workflow-guide/index.html
ning-inspire f4240ed0ae docs(guide): 测试策略升级为九层阶梯,新增 §7 仓库布局
- team-workflow-guide/index.html:#testing 扩成九层阶梯(含变异测试、编号追溯),
  新增 §7 单仓 / 嵌套 / 并列三种仓库布局与判据,修窄屏锚点遮挡与表格折行
- README / 指南 README / CHANGELOG 同步;example-project 测试规范加指针
- .agents/plan 落两轮计划:20261120-multi-repo-layout、20261120-test-strategy-chapter
2026-11-21 15:57:33 +08:00

1326 lines
54 KiB
HTML
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.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>团队 AI 编程工作流指南</title>
<style>
:root {
--bg: #f6f7f9;
--surface: #ffffff;
--ink: #1a1d24;
--muted: #5c6570;
--line: #e3e6eb;
--line-strong: #cfd4dc;
--pre: #2563eb;
--pre-soft: #eff4ff;
--mid: #0f9f6e;
--mid-soft: #eefbf5;
--setup: #7c3aed;
--setup-soft: #f5f0ff;
--accent: #c2410c;
--gate: #b45309;
--gate-bg: #fff7ed;
--code-bg: #f0f2f5;
--shadow: 0 1px 2px rgba(16,24,40,.04), 0 8px 24px rgba(16,24,40,.06);
--radius: 12px;
--font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Segoe UI", system-ui, sans-serif;
--mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
--nav-w: 200px;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
margin: 0;
font: 15px/1.65 var(--font);
color: var(--ink);
background: var(--bg);
}
a { color: var(--pre); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono {
font-family: var(--mono);
font-size: .9em;
background: var(--code-bg);
padding: .1em .35em;
border-radius: 4px;
}
pre {
font-family: var(--mono);
font-size: 12.5px;
line-height: 1.55;
background: var(--code-bg);
border: 1px solid var(--line);
border-radius: 8px;
padding: 12px 14px;
margin: 10px 0;
overflow-x: auto;
}
pre code { background: none; padding: 0; font-size: inherit; }
.wrap {
max-width: 1120px;
margin: 0 0 0 var(--nav-w);
padding: 32px 28px 80px 32px;
}
header.doc-head {
margin-bottom: 28px;
}
header.doc-head h1 {
margin: 0 0 10px;
font-size: 28px;
font-weight: 700;
letter-spacing: -.02em;
}
header.doc-head .lead {
margin: 0;
color: var(--muted);
max-width: 720px;
}
nav.toc {
position: fixed;
left: 0;
top: 0;
bottom: 0;
width: var(--nav-w);
z-index: 40;
display: flex;
flex-direction: column;
gap: 4px;
margin: 0;
padding: 24px 14px 28px;
overflow-y: auto;
background: var(--surface);
border-right: 1px solid var(--line);
box-shadow: 4px 0 24px rgba(16, 24, 40, .04);
}
nav.toc .toc-label {
margin: 0 0 10px 8px;
font-size: 11px;
font-weight: 600;
letter-spacing: .08em;
text-transform: uppercase;
color: var(--muted);
}
nav.toc a {
display: block;
padding: 8px 12px;
border: 1px solid transparent;
border-radius: 8px;
background: transparent;
color: var(--ink);
font-size: 13px;
line-height: 1.35;
}
nav.toc a:hover {
background: var(--pre-soft);
color: var(--pre);
text-decoration: none;
}
nav.toc a:focus-visible {
outline: 2px solid var(--pre);
outline-offset: 1px;
}
section {
background: var(--surface);
border: 1px solid var(--line);
border-radius: var(--radius);
box-shadow: var(--shadow);
padding: 28px 28px 32px;
margin-top: 20px;
}
section h2 {
margin: 0 0 8px;
font-size: 20px;
font-weight: 700;
}
section h3 {
margin: 24px 0 10px;
font-size: 16px;
font-weight: 600;
}
section .goal {
margin: 0 0 18px;
color: var(--muted);
}
.note {
margin: 0 0 16px;
padding: 12px 14px;
background: var(--pre-soft);
border-radius: 8px;
color: #1e3a5f;
font-size: 13.5px;
line-height: 1.55;
}
.gates {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin: 14px 0 0;
}
.gate {
display: inline-flex;
align-items: center;
gap: 6px;
padding: 6px 10px;
border-radius: 8px;
background: var(--gate-bg);
color: var(--gate);
font-size: 13px;
font-weight: 600;
}
.legend {
display: flex;
flex-wrap: wrap;
gap: 14px;
margin-top: 12px;
font-size: 13px;
color: var(--muted);
}
.legend i {
display: inline-block;
width: 10px;
height: 10px;
border-radius: 2px;
margin-right: 6px;
vertical-align: middle;
}
.legend .l-setup { background: var(--setup); }
.legend .l-pre { background: var(--pre); }
.legend .l-mid { background: var(--mid); }
/* ===== 嵌入的泳道图 ===== */
.figure {
margin: 6px 0 0;
border: 1px solid var(--line);
border-radius: var(--radius);
overflow: hidden;
background: var(--surface);
}
.figure-bar {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
gap: 8px 16px;
padding: 9px 14px;
border-bottom: 1px solid var(--line);
font-size: 13px;
color: var(--muted);
}
.figure-bar a { font-weight: 600; }
.figure iframe {
display: block;
width: 100%;
height: 560px;
border: 0;
background: #f4f4f1;
}
.figure-hint {
margin: 0;
padding: 10px 14px;
border-top: 1px solid var(--line);
font-size: 12.5px;
color: var(--muted);
}
@media (max-width: 900px) {
.figure iframe { height: 420px; }
}
/* ===== Workflow matrix ===== */
.matrix-scroller {
overflow-x: auto;
margin: 8px 0 4px;
border: 1px solid var(--line);
border-radius: 10px;
}
table.matrix {
width: 100%;
min-width: 920px;
border-collapse: collapse;
table-layout: fixed;
font-size: 13.5px;
}
table.matrix th,
table.matrix td {
border: 1px solid var(--line);
vertical-align: top;
padding: 12px 12px;
}
table.matrix thead th {
background: #f0f2f5;
font-weight: 600;
text-align: left;
color: var(--ink);
}
table.matrix .phase {
width: 44px;
padding: 0;
vertical-align: middle;
text-align: center;
color: #fff;
background-clip: padding-box;
}
table.matrix .phase-label {
display: inline-block;
writing-mode: vertical-rl;
text-orientation: upright;
font-weight: 700;
letter-spacing: .16em;
line-height: 44px;
color: #fff;
}
table.matrix .phase.setup { background: var(--setup); }
table.matrix .phase.pre { background: var(--pre); }
table.matrix .phase.mid { background: var(--mid); }
table.matrix .role {
width: 88px;
background: #fff;
text-align: center;
vertical-align: middle;
font-weight: 700;
}
table.matrix .role small {
display: block;
margin-top: 4px;
font-weight: 500;
color: var(--muted);
font-size: 11px;
}
table.matrix tbody td {
background: #fafbfc;
}
table.matrix ul {
margin: 0;
padding-left: 1.1em;
}
table.matrix li { margin: 3px 0; }
table.matrix .tool-new {
color: var(--accent);
font-family: var(--mono);
font-size: 12.5px;
font-weight: 600;
}
table.matrix .col-action { width: 28%; }
table.matrix .col-tool { width: 18%; }
table.matrix .col-in { width: 16%; }
table.matrix .col-out { width: 20%; }
table.data {
width: 100%;
border-collapse: collapse;
font-size: 14px;
margin: 8px 0 4px;
}
table.data th,
table.data td {
border: 1px solid var(--line);
padding: 8px 10px;
text-align: left;
vertical-align: top;
}
table.data th { background: #f0f2f5; font-weight: 600; }
table.data tr:nth-child(even) td { background: #fafbfc; }
/* 短列不折字(如形态名),长列仍正常换行 */
.nw { white-space: nowrap; }
ul.check { padding-left: 1.2em; }
ul.check li { margin: 4px 0; }
/* ===== Visual flowcharts ===== */
.flow {
margin: 12px 0 16px;
padding: 16px;
border: 1px solid var(--line);
border-radius: 10px;
background: #fafbfc;
overflow-x: auto;
}
.flow-col {
display: flex;
flex-direction: column;
align-items: center;
gap: 0;
min-width: min(100%, 640px);
margin: 0 auto;
}
.flow-row {
display: flex;
flex-wrap: wrap;
justify-content: center;
align-items: stretch;
gap: 12px;
width: 100%;
}
.flow-branch {
display: inline-flex;
flex-wrap: wrap;
justify-content: center;
align-items: stretch;
gap: 12px;
width: auto;
max-width: 100%;
padding: 4px 0;
}
.flow-parallel-mark {
display: flex;
align-items: center;
justify-content: center;
align-self: center;
min-width: 36px;
padding: 4px 6px;
font-size: 11px;
font-weight: 600;
color: var(--muted);
border: 1px dashed var(--line-strong);
border-radius: 8px;
background: #fff;
white-space: nowrap;
}
.flow-node {
display: flex;
flex-direction: column;
gap: 4px;
min-width: 140px;
max-width: 280px;
padding: 10px 12px;
border-radius: 10px;
border: 1px solid var(--line-strong);
background: #fff;
text-align: center;
box-shadow: 0 1px 2px rgba(16,24,40,.04);
}
.flow-node .who {
font-size: 11px;
font-weight: 600;
color: var(--muted);
letter-spacing: .02em;
}
.flow-node .what {
font-size: 13.5px;
font-weight: 600;
color: var(--ink);
line-height: 1.35;
}
.flow-node .meta {
font-size: 12px;
color: var(--muted);
font-family: var(--mono);
}
.flow-node.gate {
border-color: #fdba74;
background: var(--gate-bg);
}
.flow-node.gate .who { color: var(--gate); }
.flow-node.ok {
border-color: #86efac;
background: var(--mid-soft);
}
.flow-node.ba { border-top: 3px solid #6366f1; }
.flow-node.pm { border-top: 3px solid #8b5cf6; }
.flow-node.tl { border-top: 3px solid var(--pre); }
.flow-node.qa { border-top: 3px solid var(--mid); }
.flow-node.dev { border-top: 3px solid #0ea5e9; }
.flow-arrow {
display: flex;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
color: var(--muted);
font-size: 18px;
line-height: 1;
flex-shrink: 0;
}
.flow-arrow.down::before { content: "↓"; }
.flow-arrow.right::before { content: "→"; }
.flow-split-label {
width: 100%;
text-align: center;
font-size: 12px;
color: var(--muted);
margin-bottom: 4px;
}
.flow-lane {
display: flex;
flex-direction: column;
align-items: center;
gap: 0;
flex: 0 0 auto;
width: auto;
}
.flow-lane .flow-node {
min-width: 168px;
max-width: 220px;
}
.flow-chain {
display: flex;
flex-wrap: wrap;
align-items: center;
justify-content: center;
gap: 6px;
width: 100%;
}
.flow-chain .flow-node {
min-width: 100px;
max-width: 160px;
flex: 0 1 auto;
}
.flow-loop {
position: relative;
display: flex;
flex-direction: column;
align-items: center;
padding: 14px 18px 10px;
border: 1.5px dashed #7dd3fc;
border-radius: 14px;
background: #f0f9ff;
min-width: 150px;
}
.flow-loop-tag {
position: absolute;
top: -9px;
left: 50%;
transform: translateX(-50%);
padding: 0 8px;
font-size: 11px;
font-weight: 600;
color: #0369a1;
background: #f0f9ff;
white-space: nowrap;
}
.flow-loop .flow-node {
min-width: 140px;
max-width: 200px;
border-style: solid;
}
.flow-loop-hint {
margin-top: 6px;
font-size: 11px;
color: #0369a1;
}
.callout {
margin: 12px 0;
padding: 12px 14px;
border-left: 3px solid var(--pre);
background: var(--pre-soft);
border-radius: 0 8px 8px 0;
font-size: 14px;
}
.role-card {
border: 1px solid var(--line);
border-radius: 10px;
padding: 16px 18px;
margin-top: 12px;
background: #fff;
}
.role-card h3 { margin: 0 0 6px; }
.role-card .goal { margin-bottom: 10px; }
.pill-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.pill {
font-family: var(--mono);
font-size: 12px;
padding: 3px 8px;
border-radius: 6px;
background: var(--code-bg);
color: var(--ink);
}
footer {
margin-top: 28px;
color: var(--muted);
font-size: 13px;
text-align: center;
}
@media (max-width: 900px) {
/* 窄屏下目录变成 sticky 顶栏,锚点跳转要避开它 */
section { scroll-margin-top: 68px; }
nav.toc {
position: sticky;
top: 0;
left: auto;
bottom: auto;
width: 100%;
flex-direction: row;
flex-wrap: nowrap;
gap: 6px;
padding: 10px 12px;
overflow-x: auto;
overflow-y: hidden;
border-right: none;
border-bottom: 1px solid var(--line);
box-shadow: 0 4px 16px rgba(16, 24, 40, .06);
-webkit-overflow-scrolling: touch;
}
nav.toc .toc-label { display: none; }
nav.toc a {
flex: 0 0 auto;
white-space: nowrap;
border: 1px solid var(--line);
border-radius: 999px;
background: var(--bg);
}
.wrap {
margin-left: 0;
padding: 20px 14px 60px;
}
section { padding: 20px 16px; }
header.doc-head h1 { font-size: 22px; }
}
</style>
</head>
<body>
<nav class="toc" aria-label="目录">
<p class="toc-label">目录</p>
<a href="#overview">0. 总览</a>
<a href="#setup">1. 项目准备</a>
<a href="#design">2. 迭代前设计</a>
<a href="#dev">3. 迭代中开发</a>
<a href="#testing">4. 测试策略</a>
<a href="#roles">5. 角色手册</a>
<a href="#skills">6. Skill 对照</a>
<a href="#repos">7. 仓库布局</a>
<a href="#lane">角色协作图(嵌入)</a>
</nav>
<div class="wrap">
<header class="doc-head">
<h1>团队 AI 编程工作流指南</h1>
<p class="lead">团队级协作手册:项目怎么准备、迭代前怎么设计、迭代中怎么开发。规范硬约束在项目 <code>AGENTS.md</code>;本页讲<strong>人怎么配合</strong>,AI 只做执行。 <a href="#lane">先看角色 × 阶段泳道图 →</a></p>
</header>
<section id="lane">
<h2>角色 × 阶段泳道图</h2>
<p class="goal">行是角色,列是时间:谁在哪一列动手、把什么交给谁、在哪儿被打回。整条迭代压到一张图上。</p>
<p class="note">3 条打回边、3 道人工闸门。两处细节:<code>dev-build</code> 的四步 LOOP(实现 → 自测 → UI 对照 → 代码评审,不绿就继续改)写在节点里;<code>overnight-runner</code> 的队列用卡片堆表示——可以一直追加,但只收已确认的 Plan。</p>
<div class="figure">
<div class="figure-bar">
<span>滚轮缩放 · 拖拽平移 · 双击适应窗口</span>
<a href="flow.html" target="_blank" rel="noopener">在新窗口打开 ↗</a>
</div>
<iframe src="flow.html" title="角色 × 阶段泳道图(可缩放、可拖拽)" loading="lazy"></iframe>
<p class="figure-hint">双框带 ★ 的是人工闸门,红色虚线是打回边。如果这里没有加载(断网或缺 JointJS CDN),直接<a href="flow.html">打开 flow.html</a>。</p>
</div>
</section>
<section id="overview">
<h2>0. 团队工作流程</h2>
<p class="goal">一张图看清:谁在哪个阶段、用什么 skill、吃什么输入、吐什么产物。</p>
<p class="note">原则:人做决策,AI 做执行。规格确认后,TL 高阶技术方案与 QA 文本用例可并行;迭代中由 DEV 编写 Plan 再实现。</p>
<p class="note">这是 <strong>L3 · Human in the loop</strong> 的跑法:人按阶段点名 skill、人工过闸门。要让图自己往下走(<strong>L4 · Human on the loop</strong>,人只在岔路口决策),用 <a href="../agents-workflow-engine/graph.html"><code>agents-workflow-engine</code> 的编排图</a>;两者共用同一套 skill。</p>
<div class="matrix-scroller" role="region" aria-label="团队工作流矩阵" tabindex="0">
<table class="matrix">
<thead>
<tr>
<th style="width:42px"></th>
<th style="width:88px">人</th>
<th class="col-action">AI 驱动动作</th>
<th class="col-tool">工具和技能</th>
<th class="col-in">输入</th>
<th class="col-out">输出物</th>
</tr>
</thead>
<tbody>
<tr>
<th class="phase setup" rowspan="4" scope="rowgroup"><span class="phase-label">项目准备</span></th>
<td class="role">TL<small>装机与定规</small></td>
<td>
<ul>
<li>初始化 harness 与 docs 骨架</li>
<li>安装 SDD skill 与 MCP 工具链</li>
<li>定标准与 CI 闸门</li>
</ul>
</td>
<td>
<div><code>harness-installer</code></div>
<div><code>agile-team-sdd</code></div>
<div><code>tool-chain-installer</code></div>
</td>
<td>
<ul>
<li>空项目 / 存量仓库</li>
<li>团队技术选型</li>
</ul>
</td>
<td>
<ul>
<li><code>AGENTS.md</code> + <code>docs/</code></li>
<li><code>.agents/skills/</code></li>
<li>MCP 配置、测试闸门约定</li>
</ul>
</td>
</tr>
<tr>
<td class="role">BA<small>业务架构意图</small></td>
<td>
<ul>
<li>产品边界与「本期不做」</li>
<li>术语基线、核心聚合 + 关键字段</li>
<li>迭代规划与里程碑</li>
</ul>
</td>
<td>
<div class="tool-new"><code>ba-arch-plan</code></div>
<div><code>ba-arch-sync-back</code>(后续对齐)</div>
</td>
<td>业务目标、干系人访谈、现有系统边界</td>
<td>
<ul>
<li><code>docs/architecture/business/</code></li>
<li>product · glossary · core-domain-model · iterations</li>
<li>「核心聚合 → 建议容器」交接表</li>
</ul>
</td>
</tr>
<tr>
<td class="role">TL<small>技术架构</small></td>
<td>
<ul>
<li>C4 上下文/容器切分</li>
<li>跨迭代 ADR</li>
<li>容器能否承载核心聚合</li>
</ul>
</td>
<td>
<div class="tool-new"><code>tl-arch-plan</code></div>
<div><code>tl-arch-sync-back</code>(后续对齐)</div>
</td>
<td>业务边界与核心聚合、技术选型、干系人约束</td>
<td>
<ul>
<li><code>docs/architecture/tech/</code></li>
<li>C4 上下文/容器 · ADR 一句话表</li>
</ul>
</td>
</tr>
<tr>
<td class="role">BA / PM<small>定方向</small></td>
<td>
<ul>
<li>对齐业务目标与首迭范围</li>
<li>定迭代节奏</li>
</ul>
</td>
<td>—</td>
<td>业务背景、干系人预期</td>
<td>迭代目标一页纸(写入 <code>docs/architecture/business/iterations.md</code>)</td>
</tr>
<tr>
<th class="phase pre" rowspan="3" scope="rowgroup"><span class="phase-label">迭代前</span></th>
<td class="role">BA<small>规格 + 原型</small></td>
<td>
<ul>
<li>拷问需求,消除歧义</li>
<li>落需求规格:字段、规则、权限、验收</li>
<li>输出 HTML 原型图</li>
</ul>
</td>
<td>
<div class="tool-new"><code>ba-grill-me</code></div>
<div class="tool-new"><code>ba-write-spec</code></div>
<div><code>pm-estimate</code>(配合 PM)</div>
</td>
<td>一句话需求 / 访谈材料</td>
<td>
<ul>
<li><code>docs/features/iteration[n]/&lt;CODE&gt;-&lt;slug&gt;/spec.md</code></li>
<li><code>docs/features/iteration[n]/prototypes/</code> 原型图</li>
<li>编号 <code>R-xxx</code> / <code>AC-xxx</code></li>
</ul>
</td>
</tr>
<tr>
<td class="role">TL<small>高阶方案 ★</small></td>
<td>
<ul>
<li>需求 Review</li>
<li>编写高阶技术方案(TRD)+ Review</li>
</ul>
</td>
<td>自定义工具</td>
<td>
<ul>
<li><code>iteration[n]/*.md</code> 规格</li>
<li>原型图</li>
<li>现有 designs / 架构边界</li>
</ul>
</td>
<td>
<ul>
<li><code>high-level-design.md</code>(TRD)</li>
<li>技术边界与取舍</li>
</ul>
</td>
</tr>
<tr>
<td class="role">QA<small>用例(并行)</small></td>
<td>
<ul>
<li>按 AC/R 写 QA 文本用例</li>
<li>与 TRD 并行,规格确认后即可开始</li>
</ul>
</td>
<td>
<div class="tool-new"><code>qa-write-cases</code></div>
</td>
<td>
<ul>
<li><code>iteration[n]/*.md</code> 中的 AC / R</li>
<li>原型图(辅助)</li>
</ul>
</td>
<td>
<ul>
<li><code>docs/test-cases/e2e-cases/</code>(验收)</li>
<li>编号 <code>TC-xxx</code> 映射表</li>
</ul>
</td>
</tr>
<tr>
<th class="phase mid" rowspan="3" scope="rowgroup"><span class="phase-label">迭代中</span></th>
<td class="role">DEV<small>Plan + 实现</small></td>
<td>
<ul>
<li>编写 Plan(对照 TRD / 规格)★确认</li>
<li><code>dev-build</code> 全栈 LOOP:实现 → 真实环境 DST 自测落盘 → 原型 UI 对照落盘 → 代码评审(以记录修到绿)</li>
<li>更新事实文档、开 MR</li>
</ul>
</td>
<td>
<div class="tool-new"><code>dev-plan</code></div>
<div><code>dev-build</code>(LOOP <code>dev-self-test</code> · <code>dev-ui-review</code> · <code>dev-code-review</code>;按需 <code>dev-debug</code>)</div>
<div><code>ba-gen-facts</code> · <code>dev-create-mr</code></div>
<div><code>overnight-runner</code>(可选)</div>
</td>
<td>
<ul>
<li>TRD + 规格 + 原型图</li>
<li>TC 文本基线</li>
</ul>
</td>
<td>
<ul>
<li><code>docs/features/.../plan.md</code> 或 <code>_chores/plan-*.md</code></li>
<li>业务代码 + progress;自测 / UI / 代码评审通过</li>
<li>更新后的事实文档、MR / PR</li>
</ul>
</td>
</tr>
<tr>
<td class="role">QA<small>验收 ★</small></td>
<td>
<ul>
<li>跑 E2E 验收 + 文本勾选</li>
<li>手工 / 冒烟补测</li>
</ul>
</td>
<td>
<div><code>qa-run-e2e</code></div>
<div><code>qa-write-manual-plan</code></div>
</td>
<td>
<ul>
<li>实现产物</li>
<li>TC 文本用例</li>
</ul>
</td>
<td>
<ul>
<li>验收结论(合并闸门)</li>
<li>E2E / 手动 / 冒烟报告</li>
</ul>
</td>
</tr>
<tr>
<td class="role">TL / PM<small>发布与复盘</small></td>
<td>
<ul>
<li>上线清单(DB 单独评估)</li>
<li>复盘并把改进回写 harness</li>
</ul>
</td>
<td>
<div><code>dev-release-plan</code></div>
<div><code>pm-retro</code></div>
</td>
<td>已合并变更 + 验收记录</td>
<td>
<ul>
<li><code>docs/releases/</code></li>
<li>harness 改进项(可验证)</li>
</ul>
</td>
</tr>
</tbody>
</table>
</div>
<div class="legend">
<span><i class="l-setup"></i>项目准备</span>
<span><i class="l-pre"></i>迭代前</span>
<span><i class="l-mid"></i>迭代中</span>
</div>
<div class="gates">
<span class="gate">★ TRD 确认 · 迭代前</span>
<span class="gate">★ Plan 确认 · 编码前(DEV)</span>
<span class="gate">★ QA 验收 · 合并前</span>
</div>
</section>
<section id="setup">
<h2>1. 项目准备</h2>
<p class="goal">目标:项目「可被 harness 管理」——规范、目录、工具齐;高阶架构意图落盘。</p>
<p><strong>协作口诀</strong>:TL 装机与定规矩,BA 先落业务意图、TL 再接技术架构,QA 定闸门,BA/PM 定方向。规矩与架构未定不进迭代。</p>
<h3>1.1 谁做什么</h3>
<table class="data">
<thead><tr><th>步骤</th><th>主责</th><th>产物</th></tr></thead>
<tbody>
<tr><td>初始化 AGENTS.md + docs/</td><td>TL</td><td><code>AGENTS.md</code>、<code>docs/**</code></td></tr>
<tr><td>安装 SDD skill</td><td>TL</td><td><code>.agents/skills/</code></td></tr>
<tr><td>安装 MCP</td><td>TL</td><td><code>.mcp.json</code> / <code>opencode.jsonc</code></td></tr>
<tr><td>定标准与事实骨架</td><td>TL</td><td><code>docs/standards/</code>、<code>docs/facts/</code></td></tr>
<tr><td>业务架构意图(产品边界/术语/核心聚合/迭代规划)</td><td>BA</td><td><code>docs/architecture/business/</code></td></tr>
<tr><td>技术架构(C4/ADR,承载核心聚合)</td><td>TL</td><td><code>docs/architecture/tech/</code></td></tr>
<tr><td>定测试闸门</td><td>QA + TL</td><td><code>test:qa</code> 进 CI</td></tr>
<tr><td>业务目标与首迭范围</td><td>BA / PM</td><td><code>docs/architecture/business/iterations.md</code></td></tr>
</tbody>
</table>
<h3>1.2 接入顺序</h3>
<p>全部交给 <strong>AI Agent</strong> 按 skill 执行,人只确认目标项目路径与关键决策。顺序不能变:</p>
<ol>
<li>
<strong>铺 harness</strong> — 对 Agent 说:用 <code>harness-installer</code> 给目标项目初始化 <code>AGENTS.md</code> 与 <code>docs/</code> 骨架。<br />
完成后由 <strong>TL</strong> 补全 <code>AGENTS.md</code> 里的业务 / 架构 TODO(Agent 可起草,人必须拍板)。<br />
多仓库项目<strong>先定布局</strong>(见 <a href="#repos">§7</a>)—— 布局决定 <code>AGENTS.md</code> 与文档里写哪些路径。
</li>
<li>
<strong>装 SDD skills</strong> — 对 Agent 说:用 <code>agile-team-sdd</code> 把 27 个流程 skill 安装到目标项目的 <code>.agents/skills/</code>。
</li>
<li>
<strong>装 MCP 工具链</strong> — 对 Agent 说:用 <code>tool-chain-installer</code> 把 MCP 配置写入项目(如 <code>.mcp.json</code> / <code>opencode.jsonc</code>)。
</li>
<li>
<strong>(可选)装 overnight-runner</strong> — 需要夜跑 Plan 时,再让 Agent 安装并写好队列配置。
</li>
<li>
<strong>业务架构意图</strong> — 对 Agent 说:用 <code>ba-arch-plan</code> 起草 <code>docs/architecture/business/</code>(产品边界、术语基线、核心聚合、迭代规划),并给出「核心聚合 → 建议容器」交接表。
</li>
<li>
<strong>技术架构</strong> — 对 Agent 说:用 <code>tl-arch-plan</code> 接上一步,填 <code>docs/architecture/tech/</code>(C4 上下文/容器、跨迭代 ADR);容器要能承载上一步的核心聚合。两步都完成,architecture 才算可读。
</li>
</ol>
<div class="callout">装完 skill / MCP 后必须<strong>重启 opencode</strong>(或等价 IDE Agent),配置才生效。不要跳步:先有 <code>AGENTS.md</code> 与 <code>docs/</code>,再装 skills,路径才指向真实目录。</div>
<h3>1.3 出口条件</h3>
<ul class="check">
<li><code>AGENTS.md</code> 关键 TODO 已填</li>
<li>skill + MCP 可用</li>
<li>文档树与测试归属约定写清</li>
<li>仓库布局已定:组件在 <code>containers/</code> 下就位(单仓 / 嵌套 / 并列三者之一,见 <a href="#repos">§7</a>)</li>
<li><code>docs/architecture/</code> 已有可读的:业务侧(product 边界 / 术语 / 核心聚合 / 首迭规划)+ 技术侧(C4 / ADR)(可与装机并行,但进迭代前须齐)</li>
<li>团队对齐三条铁律(规范先于代码 / 测试先于实现 / 文档同批次)</li>
</ul>
</section>
<section id="design">
<h2>2. 迭代前方案设计</h2>
<p class="goal">目标:进开发前,业务与技术都「可测、可估、可确认」。</p>
<h3>2.1 流水线</h3>
<div class="flow" role="img" aria-label="迭代前流水线:BA 规格与原型,PM 估算,随后 TL 的 TRD 与 QA 用例并行,两边就绪进入迭代中">
<div class="flow-col">
<div class="flow-node ba">
<span class="who">BA</span>
<span class="what">拷问 → 规格 + 原型图</span>
<span class="meta">ba-grill-me · ba-write-spec</span>
</div>
<div class="flow-arrow down" aria-hidden="true"></div>
<div class="flow-node pm">
<span class="who">PM</span>
<span class="what">估算与排期</span>
<span class="meta">pm-estimate</span>
</div>
<div class="flow-arrow down" aria-hidden="true"></div>
<div class="flow-split-label">规格确认后并行</div>
<div class="flow-branch">
<div class="flow-lane">
<div class="flow-node tl gate">
<span class="who">TL · ★</span>
<span class="what">高阶技术方案 TRD</span>
<span class="meta">人工确认</span>
</div>
</div>
<div class="flow-parallel-mark" aria-hidden="true">∥</div>
<div class="flow-lane">
<div class="flow-node qa">
<span class="who">QA</span>
<span class="what">文本用例 TC</span>
<span class="meta">qa-write-cases</span>
</div>
</div>
</div>
<div class="flow-arrow down" aria-hidden="true"></div>
<div class="flow-node ok">
<span class="who">出口</span>
<span class="what">两边就绪 → 进入迭代中</span>
<span class="meta">DEV 再写 Plan</span>
</div>
</div>
</div>
<p>规格与原型落在 <code>docs/features/iteration[n]/</code>。TRD 文件为 <code>docs/features/iteration[n]/high-level-design.md</code>(skill:<code>tl-high-level-design</code>)。TRD 未确认<strong>不得进入迭代中写 Plan</strong>;QA 文本用例未齐<strong>不得声称有验收基线</strong>。</p>
<h3>2.2 交接</h3>
<table class="data">
<thead><tr><th>从 → 到</th><th>交出什么</th></tr></thead>
<tbody>
<tr><td>BA → TL / QA / DEV</td><td><code>iteration[n]/*.md</code> 规格 + 原型图 + 范围边界 + AC/R</td></tr>
<tr><td>TL → DEV</td><td>已确认 TRD(技术边界与取舍)</td></tr>
<tr><td>QA → DEV</td><td>TC 映射表(自动化可代写)</td></tr>
</tbody>
</table>
<h3>2.3 可进入迭代中 DoR</h3>
<ul class="check">
<li>本迭规格已确认(<code>docs/features/iteration[n]/&lt;CODE&gt;-&lt;slug&gt;/spec.md</code>,R / AC 齐)</li>
<li>本迭原型图已输出(<code>docs/features/iteration[n]/prototypes/</code>)</li>
<li>TRD 已人工确认</li>
<li>本迭 TC 文本用例齐,且映射到 AC/R</li>
</ul>
</section>
<section id="dev">
<h2>3. 迭代中开发</h2>
<p class="goal">目标:DEV 先写 Plan(对照 TRD),确认后再由 <code>dev-build</code> 全栈 LOOP(实现 → 自测 → UI 评审 → 代码评审);经 QA 验收后合并、可发布;复盘回写 harness。</p>
<h3>3.1 流水线</h3>
<div class="flow" role="img" aria-label="迭代中流水线:DEV 写 Plan 并确认后由 dev-build LOOP 实现与评审,QA 验收,然后开 MR、发布与复盘">
<div class="flow-col">
<div class="flow-split-label">DEV(+ AI)</div>
<div class="flow-chain">
<div class="flow-node dev gate">
<span class="who">★</span>
<span class="what">写 Plan</span>
<span class="meta">dev-plan</span>
</div>
<div class="flow-arrow right" aria-hidden="true"></div>
<div class="flow-loop" title="dev-build LOOP:实现 → self-test → ui-review → code-review;失败修 bug 回环">
<span class="flow-loop-tag">LOOP</span>
<div class="flow-node dev">
<span class="who">全栈实现</span>
<span class="what">dev-build</span>
<span class="meta">实现 → DST自测落盘 → UI对照落盘 → 评审</span>
</div>
<span class="flow-loop-hint">↻ 失败则修 bug 回环</span>
</div>
<div class="flow-arrow right" aria-hidden="true"></div>
<div class="flow-node dev">
<span class="who">事实文档</span>
<span class="what">ba-gen-facts</span>
<span class="meta">校准 facts</span>
</div>
</div>
<div class="flow-arrow down" aria-hidden="true"></div>
<div class="flow-node qa gate">
<span class="who">QA · ★ 合并闸门</span>
<span class="what">E2E + 文本勾选</span>
<span class="meta">qa-run-e2e</span>
</div>
<div class="flow-arrow down" aria-hidden="true"></div>
<div class="flow-chain">
<div class="flow-node dev">
<span class="who">DEV</span>
<span class="what">开 MR</span>
<span class="meta">dev-create-mr</span>
</div>
<div class="flow-arrow right" aria-hidden="true"></div>
<div class="flow-node tl">
<span class="who">TL</span>
<span class="what">上线清单</span>
<span class="meta">dev-release-plan</span>
</div>
<div class="flow-arrow right" aria-hidden="true"></div>
<div class="flow-node pm">
<span class="who">PM</span>
<span class="what">复盘回写</span>
<span class="meta">pm-retro</span>
</div>
</div>
</div>
</div>
<div class="callout">Plan 未确认<strong>不得写实现</strong>。<code>overnight-runner</code> 的队列可以<strong>一直追加</strong>已确认 Plan,但它只跑已确认的 Plan;不做 Plan / TRD 闸门本身。</div>
<h3>3.2 并行边界</h3>
<ul>
<li>多 DEV 可并行,契约以已确认 Plan + <code>api.yaml</code> 为准(并服从 TRD 边界)</li>
<li>QA 自动化可由 DEV 代写,勾选与放行权在 QA</li>
<li>自测绿 ≠ 可合;QA 过 ≠ 可忽略自测红</li>
<li>规格外行为 = 缺陷(除非 BA 认可)</li>
</ul>
<h3>3.3 Definition of Done</h3>
<ul class="check">
<li>Plan 已确认且按 Plan 实现</li>
<li>每条 AC / R 都有对应 QA 用例且通过;文本用例勾选完毕</li>
<li><code>dev-build</code> LOOP 完成:<code>*-self-test.md</code> 通过(真实本地环境 + DST)、有 UI 则 <code>*-ui-review.md</code> 通过、code-review 自查通过</li>
<li>关键 API 覆盖 Happy Path + 失败分支;事实文档已更新;无遗留 TODO / 调试代码</li>
<li>上线清单完成(TL);复盘改进已回写 harness(PM)</li>
</ul>
</section>
<section id="testing">
<h2>4. 测试策略与归属</h2>
<p class="goal">目标:九层测试各有人管、各有落点、各有闸门 —— 少一层,缺陷就往下一层漏。</p>
<p>AI 写的用例便宜,但「<strong>不可信</strong>」才是默认状态。所以策略里既有「谁写」,也有「用例本身怎么被验证」—— 后者靠 4.2 的变异测试。</p>
<h3>4.1 策略阶梯</h3>
<table class="data">
<thead><tr><th class="nw">层</th><th class="nw">谁做</th><th>框架落点(skill · 命令 · 落盘)</th><th>不过会怎样</th></tr></thead>
<tbody>
<tr><td class="nw">Lint / 静态检查</td><td class="nw">DEV<br />(TL 定命令)</td><td><code>AGENTS.md</code> §10 写死命令 + CI 拦;<strong>无专属 skill</strong></td><td>不能提交</td></tr>
<tr><td class="nw">Code Review</td><td class="nw">DEV + AI 互评</td><td><code>dev-build</code> 第 ④ 步 <code>dev-code-review</code>:对照 AGENTS / standards / facts</td><td>不能开 MR</td></tr>
<tr><td class="nw">单元测试</td><td class="nw">DEV</td><td><code>dev-self-test</code>:<code>mvn test</code>(Domain / Application)、前端 <code>vitest</code></td><td>不进自测</td></tr>
<tr><td class="nw">API 测试</td><td class="nw">DEV</td><td><code>dev-self-test</code>:RestAssured 打 <code>localhost</code>(<code>*ControllerTest</code>),先起真实环境再跑</td><td>不进自测</td></tr>
<tr><td class="nw">研发自测 ·<br />MCP 浏览器走查</td><td class="nw">DEV</td><td><code>dev-build</code> 第 ③ 步 <code>dev-ui-review</code>:原型对照 + <code>chrome-devtools</code> MCP 走查,落盘 <code>{planStem}-ui-review.md</code></td><td>回第 ① 步改</td></tr>
<tr><td class="nw">QA · E2E</td><td class="nw">QA</td><td><code>qa-write-cases</code>(<code>TC-xxx</code> 文本用例)→ <code>qa-run-e2e</code>(<code>e2e/tests/qa/</code> + 规格覆盖核对)</td><td><strong>合并闸门</strong></td></tr>
<tr><td class="nw">QA · 变异测试</td><td class="nw">QA</td><td>跑在 E2E 之后,检查用例抓不抓得住缺陷;工具项目自选(Java 用 PIT / 前端用 Stryker)</td><td>回退重跑自测</td></tr>
<tr><td class="nw">QA · 人工补测</td><td class="nw">QA</td><td><code>qa-write-manual-plan</code>(<code>docs/test-cases/manual-cases/</code>):自动化难覆盖 / 需人判断</td><td>不验收</td></tr>
<tr><td class="nw">QA · 冒烟</td><td class="nw">QA</td><td><code>qa-write-manual-plan</code>(<code>smoking-cases/</code>):发版前 5 分钟跑完的最小集</td><td>不上线</td></tr>
</tbody>
</table>
<div class="note"><strong>迁移期规则</strong>:老项目里 <code>e2e/tests/dev/</code> 可以继续跑,但<strong>不再新增</strong>;新项目研发自测直接走 MCP 走查,E2E 只归 QA —— 同一件事两套 E2E,必然漂移。</div>
<h3>4.2 变异测试:验证用例「有没有牙」</h3>
<p>AI 可以写出很像样的 E2E,却只断言「页面上有个数字」—— 实现改坏了它照样绿。
<strong>用例存在 ≠ 用例能证伪</strong>,这是 AI 测试的默认风险,也是它需要单独一层防护的原因。</p>
<ul>
<li><strong>怎么做</strong>:往被测代码里注入小改动(改比较符、删一行校验、反转条件),再跑 E2E。
用例<strong>必须变红</strong>;没变红就说明这条用例抓不住这个缺陷</li>
<li><strong>判据</strong>:有效变异杀光(或达到项目约定阈值),E2E 才算可信;
<strong>不许</strong>登记成「已知债务」放行 —— 缺口不是债务</li>
<li><strong>别误用</strong>:环境不稳、数据没隔离会造成假「没杀死」,先排除不稳定再下结论</li>
</ul>
<div class="callout"><strong>变异测试失败 → 回研发自测</strong>,而不是把断言改一改了事。
失败的含义是「用例太弱,也就是自测那一步没做扎实」:回 <code>dev-self-test</code> / <code>dev-ui-review</code> 重跑,
把断言补到能证伪,再从第 ② / ③ 步回到 E2E —— 不让弱用例带着「全绿」进合并。</div>
<h3>4.3 归属判定</h3>
<p><strong>归属看谁定义、谁判定,不看谁敲的代码</strong>:<strong>开发自测</strong>对「我写的代码」负责;
<strong>QA 测试</strong>对「需求有没有被实现」负责。</p>
<table class="data">
<thead>
<tr><th>维度</th><th>开发自测</th><th>QA 测试</th></tr>
</thead>
<tbody>
<tr><td>验证什么</td><td>代码按 Plan 工作</td><td>系统符合需求规格</td></tr>
<tr><td>判定人</td><td>开发本人</td><td><strong>QA</strong></td></tr>
<tr><td>编号</td><td>无(用 <code>DST-xxx</code> 表达意图)</td><td><code>TC-xxx</code></td></tr>
<tr><td>位置</td><td>源码旁(<code>*Test.java</code>、<code>*.test.ts</code>)+ 项目同目录 <code>*-self-test.md</code></td><td><code>docs/</code> 用例库、<code>e2e/tests/qa/</code></td></tr>
<tr><td>合并闸门</td><td>否</td><td><strong>是</strong></td></tr>
</tbody>
</table>
<h3>4.4 编号与追溯</h3>
<ul class="check">
<li>每条 <code>R-xxx</code> / <code>AC-xxx</code> → 至少一条 <code>TC-xxx</code>(QA 用例),文本用例与自动化用例共用编号</li>
<li>研发自测不编 <code>TC-</code> 号,按 Plan 的 <code>DST-xxx</code> 执行,结果落盘到 <code>{planStem}-self-test.md</code></li>
</ul>
</section>
<section id="roles">
<h2>5. 角色手册(速查)</h2>
<div class="role-card">
<h3>BA · 业务分析</h3>
<p class="goal">让开发不需要猜就能开始做。项目准备阶段先立业务架构意图(边界 / 术语 / 核心聚合 / 迭代规划);逐迭代写规格与 HTML 原型图,本迭产物放在 <code>docs/features/iteration[n]/</code>。规格写「做什么」,不写表名/SQL。</p>
<div class="pill-row">
<span class="pill">ba-arch-plan</span><span class="pill">ba-grill-me</span><span class="pill">ba-write-spec</span>
</div>
</div>
<div class="role-card">
<h3>PM · 项目经理</h3>
<p class="goal">估算有据;复盘必须落到可验证的 harness 文件改动。</p>
<div class="pill-row">
<span class="pill">pm-estimate</span><span class="pill">pm-retro</span>
</div>
</div>
<div class="role-card">
<h3>TL · 技术负责人</h3>
<p class="goal">装机定规;项目准备阶段接 BA 的业务边界切 C4/ADR;迭代前写高阶技术方案(TRD)并确认;迭代中做代码评审与发布清单。工具链与密钥不落盘也归 TL。</p>
<div class="pill-row">
<span class="pill">tl-arch-plan</span><span class="pill">tl-high-level-design</span><span class="pill">dev-code-review</span><span class="pill">ba-gen-facts</span><span class="pill">dev-release-plan</span>
</div>
</div>
<div class="role-card">
<h3>DEV · 开发</h3>
<p class="goal">迭代中先写 Plan(对照 TRD / 规格),确认后由 <code>dev-build</code> LOOP 实现、自测、UI 与代码评审。复用现有模式,不自创;自测不写 TC 编号。</p>
<div class="pill-row">
<span class="pill">dev-plan</span><span class="pill">dev-build</span><span class="pill">dev-self-test</span><span class="pill">dev-ui-review</span><span class="pill">dev-code-review</span><span class="pill">dev-debug</span>
</div>
</div>
<div class="role-card">
<h3>QA · 测试</h3>
<p class="goal">定义与判定权归 QA。先文本用例,再自动化;不过不能合。</p>
<div class="pill-row">
<span class="pill">qa-write-cases</span><span class="pill">qa-run-e2e</span><span class="pill">qa-write-manual-plan</span>
</div>
</div>
<div class="role-card">
<h3>AI Agent</h3>
<p class="goal">可靠执行者,不是打字机。需求/规范有歧义 → 停下来问。不把「自测全绿」写成「需求已满足」。</p>
</div>
</section>
<section id="skills">
<h2>6. Skill 与步骤对照</h2>
<table class="data">
<thead><tr><th>步骤</th><th>阶段</th><th>skill</th><th>产出</th></tr></thead>
<tbody>
<tr><td>业务架构意图</td><td>§1</td><td><code>ba-arch-plan</code></td><td><code>docs/architecture/business/</code>(product · glossary · core-domain-model · iterations)+ 「核心聚合 → 建议容器」</td></tr>
<tr><td>技术架构</td><td>§1</td><td><code>tl-arch-plan</code></td><td><code>docs/architecture/tech/</code>(C4 上下文/容器 · ADR)</td></tr>
<tr><td>拷问</td><td>§2</td><td><code>ba-grill-me</code></td><td>澄清纪要</td></tr>
<tr><td>写规格 + 原型</td><td>§2</td><td><code>ba-write-spec</code></td><td><code>docs/features/iteration[n]/&lt;CODE&gt;-&lt;slug&gt;/spec.md</code> + <code>prototypes/</code></td></tr>
<tr><td>估算</td><td>§2</td><td><code>pm-estimate</code></td><td>点数与人日</td></tr>
<tr><td>高阶技术方案</td><td>§2</td><td><code>tl-high-level-design</code></td><td><code>docs/features/iteration[n]/high-level-design.md</code>(人工确认)</td></tr>
<tr><td>QA 文本用例</td><td>§2 并行</td><td><code>qa-write-cases</code></td><td><code>docs/test-cases/e2e-cases/</code></td></tr>
<tr><td>手动 / 冒烟</td><td>§3</td><td><code>qa-write-manual-plan</code></td><td><code>docs/test-cases/manual-cases/</code> · <code>smoking-cases/</code></td></tr>
<tr><td>写 Plan</td><td>§3</td><td><code>dev-plan</code></td><td>feature <code>plan.md</code> / <code>_chores/</code>(人工确认)</td></tr>
<tr><td>全栈实现 LOOP</td><td>§3</td><td><code>dev-build</code>(LOOP <code>dev-self-test</code> → <code>dev-ui-review</code> → <code>dev-code-review</code>;按需 <code>dev-debug</code>)</td><td>代码 + progress + <code>*-self-test.md</code> / <code>*-ui-review.md</code> 通过</td></tr>
<tr><td>开发自测(可单跑)</td><td>§3</td><td><code>dev-self-test</code></td><td>真实本地环境 + DST;记录 <code>*-self-test.md</code></td></tr>
<tr><td>更新事实文档</td><td>§3</td><td><code>ba-gen-facts</code></td><td><code>docs/facts/</code></td></tr>
<tr><td>开 MR</td><td>§3</td><td><code>dev-create-mr</code></td><td>MR / PR</td></tr>
<tr><td>验收</td><td>§3</td><td><code>qa-run-e2e</code></td><td>验收报告</td></tr>
<tr><td>上线</td><td>§3</td><td><code>dev-release-plan</code></td><td><code>docs/releases/</code></td></tr>
<tr><td>复盘</td><td>§3</td><td><code>pm-retro</code></td><td>改进 → harness</td></tr>
</tbody>
</table>
</section>
<section id="repos">
<h2>7. 仓库布局:单仓 / 嵌套 / 并列</h2>
<p class="goal">目标:harness 与业务代码怎么放,一开始就定下来 —— 装机时的目标路径、文档里的链接、CI 的 checkout 都依赖它。</p>
<div class="note"><strong>默认选方式二(嵌套)</strong>:主仓库装 harness,业务组件以 submodule 挂在 <code>containers/&lt;组件&gt;</code>。只有当「组件少、没人管权限」或「harness 要给多个产品复用」时才偏离。</div>
<h3>7.1 先选一种</h3>
<table class="data">
<thead><tr><th>你的情况</th><th>选</th><th>一句话理由</th></tr></thead>
<tbody>
<tr><td>一个产品,前后端 + 文档都是同一拨人</td><td>方式一 · 单仓</td><td>路径最简单,没有指针要维护</td></tr>
<tr><td>业务代码已有独立仓库 / 要按组件切权限与发布</td><td><strong>方式二 · 嵌套</strong>(推荐)</td><td>目录路径与单仓完全一致,skill 与占位符零改动</td></tr>
<tr><td>harness 是平台团队交付物,要服务 N 个产品</td><td>方式三 · 并列</td><td>解耦彻底,代价是 CI 与文档链接都要跨仓</td></tr>
</tbody>
</table>
<h3>7.2 三种形态对比</h3>
<table class="data">
<thead><tr><th>维度</th><th>一 · 单仓</th><th>二 · 嵌套(推荐)</th><th>三 · 并列</th></tr></thead>
<tbody>
<tr><td>目录长相</td><td>一个仓全装下</td><td>主仓 + <code>containers/*</code> 子模块</td><td>两个平级仓库,靠 <code>../</code> 关联</td></tr>
<tr><td>harness 在哪</td><td>同仓</td><td>主仓(与 <code>docs/</code> 同级)</td><td>独立仓</td></tr>
<tr><td>clone 后能不能直接跑</td><td>可以</td><td>要 <code>--recurse-submodules</code></td><td>要 clone 两个仓并保持目录结构</td></tr>
<tr><td>权限边界</td><td>无(全员全仓)</td><td>按组件仓切,主仓只放文档与 harness</td><td>按仓切,harness 可只读</td></tr>
<tr><td>agent 工作区</td><td>一个目录</td><td><strong>一个目录</strong>(子模块就在里面)</td><td>两个目录,agent 通常只能看一个</td></tr>
<tr><td>升级 harness</td><td>直接改</td><td>主仓单独一次提交</td><td>独立仓发版,各产品各自跟进</td></tr>
<tr><td>主要代价</td><td>仓库膨胀、CI 全量</td><td>指针要跟着子仓提交走</td><td>跨仓路径与链接极易断</td></tr>
</tbody>
</table>
<h3>7.3 方式一 · 单仓(mono repo)</h3>
<pre><code>my-product/
├── AGENTS.md .agents/skills/ .mcp.json
├── docs/ architecture · features · facts · standards
├── containers/ backend/ frontend/ ← 就是普通目录
└── e2e/</code></pre>
<ul>
<li><strong>何时选</strong>:单产品、组件 1–3 个、团队规模小;<strong>新项目起步的默认选择</strong></li>
<li><code>example-project/</code> 就是这个形态 —— 先按它长起来,撑不住再拆</li>
<li><strong>坑</strong>:仓库变大后 clone 慢、CI 每次全量、没法「后端仓只给后端同学写权限」</li>
<li><strong>何时该拆</strong>:单目录超过 ~2GB,或 CI 全量已超过 15 分钟</li>
</ul>
<h3>7.4 方式二 · 嵌套仓库(推荐)</h3>
<pre><code>my-product/ ← 主仓库:harness + 文档 + 胶水
├── AGENTS.md
├── .agents/skills/ ← 27 个 skill(随主仓分发)
├── docs/ ← architecture / features / facts / standards
├── containers/
│ ├── backend/ ← submodule → git@…/svc-backend.git
│ └── frontend/ ← submodule → git@…/web-app.git
└── e2e/</code></pre>
<p><strong>为什么推荐</strong>:<code>containers/backend</code> 与单仓里的普通目录<strong>路径完全一样</strong>,
所以 <code>AGENTS.md</code>、27 个 skill、占位符(<code>BACKEND_DIR</code> / <code>FRONTEND_DIR</code>)、
测试命令(<code>cd containers/backend &amp;&amp; mvn test</code>)一个字都不用改;
<code>init-harness.sh</code> 的目录探测本来就优先 <code>containers/backend|frontend</code>。
权限与发布仍按子仓库走,而 agent 只要打开主仓<strong>一个</strong>工作区。</p>
<pre><code># 主仓里挂子仓(子仓必须已有远端仓库)
git submodule add git@github.com:org/svc-backend.git containers/backend
git submodule add git@github.com:org/web-app.git containers/frontend
# 新人 clone(漏了 --recursive 就补这一步)
git clone --recurse-submodules git@github.com:org/my-product.git
git submodule update --init --recursive</code></pre>
<p><strong>五条铁律</strong>:</p>
<ol>
<li><strong>先子仓、后主仓</strong>:代码改动必须先在 <code>containers/backend</code> 里 commit + push,
再回主仓 commit 那个指针。反了就等于「主仓指向一个没有你代码的 commit」</li>
<li><strong>指针钉 commit,不钉分支</strong>:要跟分支就显式 <code>git submodule update --remote</code>,并且知道 CI 会跟着漂</li>
<li><strong>文档只留主仓</strong>:<code>docs/features/</code>、<code>docs/architecture/</code> 不进子仓库 —— 否则同一份规格两处版本</li>
<li><strong>构建产物各自 ignore</strong>:<code>containers/*/target</code>、<code>node_modules</code>、<code>dist</code> 在各自仓里管</li>
<li><strong>子仓可见性</strong>:看不到子仓的人等于看不到代码;至少要读权限,CI 用机器账号拉</li>
</ol>
<h3>7.5 方式三 · 独立 harness 仓库(并列)</h3>
<pre><code>workspace/
├── harness/ ← 上下文 + skills + 文档骨架(独立仓库,平台团队维护)
└── product/ ← 业务代码(独立仓库)</code></pre>
<ul>
<li>关联靠<strong>相对位置</strong>:<code>../harness</code>、<code>../product</code></li>
<li>装进 <code>product</code> 的产物必须用 <code>PATH_MODE=relative</code> —— 绝对路径会把安装机的主目录写进 skill</li>
<li>适合:多个产品共用一套流程、harness 有独立发版节奏、harness 仓允许只读</li>
<li><strong>坑</strong>:CI 要 checkout 两次(<code>actions/checkout</code> 的 <code>path:</code> 参数)、
跨仓相对链接一改就断、MR 里看不到「流程改动 + 代码改动」的完整 diff</li>
</ul>
<div class="callout"><strong>最大的坑是 agent 的工作区边界</strong>:IDE Agent 通常只认打开的那个目录,
<code>../harness/docs/…</code> 多半读不到。现实中只有两种用法 ——
<strong>人切换目录</strong>(装机时站在 <code>product</code>,查架构文档时切到 <code>harness</code>),
或者<strong>把 harness 用符号链接 / submodule 挂进 <code>product</code></strong>(这时其实已经退化成方式二)。</div>
<h3>7.6 三种形态下怎么升级 harness</h3>
<table class="data">
<thead><tr><th class="nw">形态</th><th>升级动作</th><th>注意</th></tr></thead>
<tbody>
<tr><td class="nw">单仓</td><td>直接在仓里跑三个安装器</td><td>与业务改动在同一个 MR,容易一起评审</td></tr>
<tr><td class="nw">嵌套</td><td>在<strong>主仓</strong>跑三个安装器</td><td><strong>不要</strong>在 <code>containers/*</code> 里跑 —— 子仓里的 skill 副本是无效副本</td></tr>
<tr><td class="nw">并列</td><td>在 <code>harness</code> 仓改,再 <code>PATH_MODE=relative</code> 装进 <code>product</code></td><td>装完要提交 <code>product</code> 里的 <code>.agents/</code> 与 <code>docs/</code></td></tr>
</tbody>
</table>
<h3>7.7 反模式</h3>
<ul class="check">
<li>把 harness <strong>复制</strong>进多个仓各自改 → 立刻漂移,同一套 skill 各有各的版本</li>
<li>跨仓用<strong>绝对路径</strong>(<code>/Users/…</code>、<code>/home/…</code>)引用 harness → 换机器即断</li>
<li>submodule 指向<strong>个人分支</strong> → 别人拉不到</li>
<li>子仓 A 里再挂子仓 B,深度超过两层 → 指针地狱,没人敢升级</li>
</ul>
</section>
<footer>
team-workflow-guide · 打开本文件即可预览 · 规范细节见各项目 <code>AGENTS.md</code>
</footer>
</div>
</body>
</html>