create-harness-vibe-coding 0.1.2 → 0.1.4

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 (40) hide show
  1. package/README.md +166 -0
  2. package/package.json +3 -4
  3. package/src/generator.js +3 -5
  4. package/src/index.js +8 -8
  5. package/templates/common/.claude/agents/architect.md +35 -0
  6. package/templates/common/.claude/agents/debugger.md +42 -0
  7. package/templates/common/.claude/agents/docs-researcher.md +43 -0
  8. package/templates/common/.claude/agents/implementer.md +41 -0
  9. package/templates/common/.claude/agents/planner.md +35 -0
  10. package/templates/common/.claude/agents/researcher.md +42 -0
  11. package/templates/common/.claude/agents/reviewer.md +34 -0
  12. package/templates/common/.claude/agents/test-writer.md +39 -0
  13. package/templates/common/.claude/agents/verifier.md +33 -0
  14. package/templates/common/.claude/rules/ecc/common.md +25 -22
  15. package/templates/common/.claude/skills/harness-build-loop/SKILL.md +21 -0
  16. package/templates/common/.claude/skills/harness-context/SKILL.md +24 -0
  17. package/templates/common/.claude/skills/harness-lifecycle/SKILL.md +19 -0
  18. package/templates/common/.claude/skills/harness-research/SKILL.md +29 -0
  19. package/templates/common/.claude/skills/harness-router/SKILL.md +14 -0
  20. package/templates/common/AGENTS.md +3 -1
  21. package/templates/common/CLAUDE.md +30 -33
  22. package/templates/common/MEMORY.md +30 -7
  23. package/templates/common/SETUP.md +42 -68
  24. package/templates/common/docs/README.md +81 -96
  25. package/templates/common/docs/domain/ports.md +26 -26
  26. package/templates/common/docs/features/_template.md +34 -25
  27. package/templates/common/docs/harness/PLAN.md +80 -0
  28. package/templates/common/docs/harness/agent-workflow.md +57 -116
  29. package/templates/common/docs/harness/architecture.md +51 -48
  30. package/templates/common/docs/harness/context-loading.md +93 -0
  31. package/templates/common/docs/harness/data-flow.md +20 -20
  32. package/templates/common/docs/harness/dispatch.md +82 -0
  33. package/templates/common/docs/harness/extension.md +67 -0
  34. package/templates/common/docs/harness/lifecycle.md +33 -0
  35. package/templates/common/docs/harness/state-machines.md +15 -15
  36. package/templates/common/docs/research/PRD.md +25 -23
  37. package/templates/common/docs/research/README.md +121 -0
  38. package/templates/common/docs/research/research-results.md +66 -0
  39. package/templates/common/scripts/validate-harness.mjs +207 -0
  40. package/templates/common/docs/research/scaffolds.md +0 -60
@@ -1,145 +1,86 @@
1
- # Agent Workflow Harness
1
+ # Agent Workflow
2
2
 
3
- > **职责**:约束 agent 如何实现一个功能。它不是 runtime 代码架构,而是 engineering harness:防止 AI 跳过需求、乱改边界、缺测试、没有闭环。
4
- >
5
- > **原则**:小任务轻流程,大任务有文档;用测试和边界检查约束 agent,而不是靠长提示词。
3
+ Use when implementing, reviewing, debugging, or coordinating subagents.
6
4
 
7
- ---
8
-
9
- ## 1. 什么时候必须开 Feature Doc
10
-
11
- 使用 [../features/_template.md](../features/_template.md) 创建一个新的 `docs/features/{{FEATURE_SLUG}}.md`。
12
-
13
- 必须开文档:
14
- - 新增功能或用户可见行为。
15
- - 修改跨层契约、端口、状态机、数据流或权限规则。
16
- - 影响多个模块,或预计超过一个短会话。
17
- - 修复边界不清的 bug,需要先定义期望行为。
18
- - 需要 subagents 分工、TDD 或人工审批。
19
-
20
- 可以不开文档:
21
- - 拼写、链接、注释等纯文档小修。
22
- - 单测试断言或单行安全修复,且边界完全清楚。
23
- - 只读调查或一次性命令输出。
24
-
25
- 如果不确定,开一个短 feature doc。短文档比隐含假设便宜。
26
-
27
- ---
28
-
29
- ## 2. Kiro-lite 流程
30
-
31
- 每个非平凡功能按一个文件走完四段,不默认拆多个文件。
32
-
33
- 1. **Requirements**:写清目标、非目标、验收标准。
34
- 2. **Design**:写清影响范围、允许修改文件、不允许修改文件、接口/状态/数据流变化。
35
- 3. **Tasks**:拆成可验证任务,每个任务有 owner、write set、验证命令。
36
- 4. **Verification**:记录测试结果、边界检查、文档同步、剩余风险。
37
-
38
- 只有当 feature doc 超过约 200 行,或任务需要多人/多 agent 长时间并行时,才升级为目录:
5
+ ## ReAct Loop
39
6
 
40
7
  ```text
41
- docs/features/{{FEATURE_SLUG}}/
42
- ├── requirements.md
43
- ├── design.md
44
- ├── tasks.md
45
- └── verification.md
8
+ Observe -> Load minimal context -> Plan -> Act -> Verify -> Update docs/harness/PLAN.md
46
9
  ```
47
10
 
48
- ---
49
-
50
- ## 3. Subagent 分工
51
-
52
- Subagent 是分工工具,不是责任转移。主 agent 负责最终集成、验证和解释。
11
+ If context grows, load [context-loading.md](context-loading.md) and split the work. If more than one agent is useful, load [dispatch.md](dispatch.md).
53
12
 
54
- | 角色 | 允许做 | 禁止做 | 输出 |
55
- | --- | --- | --- | --- |
56
- | Explorer | 只读调查、找上下文、列风险 | 修改文件、重构、下结论替代验证 | 相关文件、风险点、建议测试 |
57
- | Test Writer | 只写/改测试和测试 fixtures | 改生产代码、放宽断言 | 失败测试、测试意图 |
58
- | Implementer | 在指定 write set 内实现 | 触碰未授权文件、扩大 scope | 改动文件、实现说明 |
59
- | Reviewer | 只读审查边界、过度设计、缺测试 | 修改代码、重排任务 | findings、severity、文件行号 |
60
- | Verifier | 运行验证命令、汇总结果 | 改业务代码掩盖失败 | 命令、结果、失败原因 |
13
+ ## Feature Packet
61
14
 
62
- 分工规则:
63
- - 同一时间并行 subagents 的 write set 必须不重叠。
64
- - Explorer 和 Reviewer 默认只读。
65
- - Test Writer 必须先于 Implementer,除非是纯文档或无法自动测试的变更。
66
- - Implementer 只能执行 feature doc 里列出的 tasks。
67
- - Verifier 的失败结果必须写回 feature doc,不能只在聊天里口头说明。
15
+ Create `docs/features/{{FEATURE_SLUG}}.md` from [../features/_template.md](../features/_template.md) when work changes behavior, touches multiple files, crosses layers, or needs more than one short session.
68
16
 
69
- ---
17
+ The packet must contain:
70
18
 
71
- ## 4. TDD 闭环
19
+ - requirements and non-goals
20
+ - acceptance criteria
21
+ - allowed write set and forbidden scope
22
+ - task list with verification commands
23
+ - test results and residual risks
72
24
 
73
- 默认闭环:
25
+ ## Standard Build Loop
74
26
 
75
27
  ```text
76
- feature doc -> failing test -> minimal implementation -> tests pass -> boundary check -> docs sync -> review -> close
28
+ PRD/feature packet
29
+ -> failing test or manual check
30
+ -> minimal implementation
31
+ -> verification
32
+ -> review
33
+ -> docs sync
34
+ -> close or iterate
77
35
  ```
78
36
 
79
- TDD 规则:
80
- - 新行为先写失败测试,再实现。
81
- - bug fix 先写复现测试,再修复。
82
- - 重构先记录现有测试,再移动代码,最后证明行为未变。
83
- - 无法自动测试时,feature doc 必须写明人工验证步骤和不可自动化原因。
84
- - 不允许为了通过测试删除关键断言、放宽边界测试或跳过失败测试。
85
-
86
- ---
87
-
88
- ## 4.1 矛盾处理
89
-
90
- 当 agent 发现 PRD、architecture、ports、data-flow、state-machines、tests 或代码互相矛盾时:
91
-
92
- 1. 停止实现,不继续猜测。
93
- 2. 在 feature doc 的 Decision Log 记录冲突位置、冲突内容、可选解释和推荐选择。
94
- 3. 如果冲突影响安全边界、端口合同、状态机或用户可见行为,先询问维护者。
95
- 4. 如果冲突只影响命名、注释或明显过期文档,可以按代码和测试事实修正 docs,并在 Verification 记录原因。
96
- 5. 修正后再继续 TDD 闭环。
37
+ ## Subagent Use
97
38
 
98
- ---
39
+ Use subagents when a task needs broad reading, parallel work, cross-layer changes, independent review, or isolated debugging.
99
40
 
100
- ## 5. Write Set 和边界
41
+ Before spawn, define:
101
42
 
102
- Feature doc 必须写:
103
- - **Allowed write set**:本次允许修改哪些文件/目录。
104
- - **Forbidden scope**:明确不碰哪些文件/行为。
105
- - **Architecture impact**:是否影响 `architecture.md`、`ports.md`、`data-flow.md`、`state-machines.md`。
106
- - **Rollback note**:失败时如何回退本次改动,不要求回退用户已有改动。
43
+ - role
44
+ - task
45
+ - mode
46
+ - read boundary
47
+ - write boundary
48
+ - dependency
49
+ - injected docs from [context-loading.md](context-loading.md)
50
+ - return format
107
51
 
108
- 默认禁止:
109
- - 顺手重构无关模块。
110
- - 为了实现一个功能修改公共契约但不更新 docs。
111
- - 让 harness 承担 domain 业务判断。
112
- - 绕过权限、审计、状态机和边界测试。
52
+ Rules:
113
53
 
114
- ---
54
+ - Explorer Pass, Reviewer, and Verifier are read-only.
55
+ - Researcher and Docs Researcher are read-only unless explicitly asked to return a docs patch.
56
+ - Planner and Architect are read-only unless explicitly asked to return a docs patch.
57
+ - Test Writer writes tests before Implementer writes production code.
58
+ - Implementer only writes inside its declared write set.
59
+ - Writing agents run serially unless write sets are disjoint.
60
+ - Debugger fixes the smallest failing path, not adjacent design.
61
+ - Main agent integrates summaries, resolves conflicts, and runs final verification.
115
62
 
116
- ## 6. 完成标准
63
+ ## Parallel Dispatch
117
64
 
118
- 一个 feature 只有同时满足这些条件才算完成:
119
- - Requirements 的验收标准逐条可验证。
120
- - Tasks 全部完成或明确取消并说明原因。
121
- - 新增/修改行为有测试或人工验证记录。
122
- - 测试框架(如 pytest、vitest、go test)通过;如果不能通过,记录具体失败和是否与本次变更相关。
123
- - 架构边界测试通过,或 feature doc 记录为什么需要改变边界。
124
- - 受影响 docs 已同步。
125
- - Reviewer 没有未处理的 critical/high findings。
65
+ Use [dispatch.md](dispatch.md) for multi-agent work. Default to at most three active agents. Prefer parallel read-only work first, then serial writes.
126
66
 
127
- ## 6.1 快车道
67
+ Every dispatched agent returns the handoff format defined in [dispatch.md](dispatch.md).
128
68
 
129
- 满足以下全部条件时,可以不开完整 feature doc,但必须在提交说明或聊天结果里写清验证:
69
+ ## Conflict Rule
130
70
 
131
- - 只影响拼写、链接、注释、单个测试断言或单行安全修复。
132
- - 不改变跨层端口、状态机、数据流、权限、审计或用户可见行为。
133
- - 不新增依赖,不移动文件,不扩大 public API。
134
- - 能用一个命令或一次人工检查验证。
71
+ If PRD, docs/harness/PLAN.md, architecture, ports, tests, or code disagree:
135
72
 
136
- 如果快车道过程中发现影响范围变大,立即补 feature doc。
73
+ 1. stop implementation
74
+ 2. record the conflict in `docs/harness/PLAN.md` or the feature doc
75
+ 3. choose the smallest reversible decision
76
+ 4. ask the maintainer when user-visible behavior or security is affected
137
77
 
138
- ---
78
+ ## Completion Gate
139
79
 
140
- ## 7. 外部参考
80
+ Close only when:
141
81
 
142
- - OpenAI ExecPlans:复杂任务要有自包含、可恢复、可验证的执行计划。
143
- - GitHub Spec Kit:constitution -> specify -> plan -> tasks -> implement。
144
- - Kiro Specs:requirements -> design -> tasks,适合约束 agent 先想清楚再写代码。
145
- - Claude Code Subagents / Hooks:focused subagents、权限限制、hook-based guardrails。
82
+ - acceptance criteria are satisfied
83
+ - verification evidence is recorded
84
+ - architecture, ports, data-flow, or state docs are synced if affected
85
+ - no unresolved critical/high review findings remain
86
+ - `docs/harness/PLAN.md` states the final status or next iteration
@@ -1,87 +1,90 @@
1
1
  # Harness Architecture — {{projectName}}
2
2
 
3
- > **职责**:定义系统的分层结构、组件全景和关键设计决策。
4
- > **不写什么**:代码细节(AI 能读代码)、API 文档(放 docstring)。
3
+ > **Responsibility**: Defines the system layering structure, component overview, and key design decisions.
4
+ > **Does NOT cover**: Code details (AI can read code), API documentation (placed in docstrings).
5
5
  >
6
- > 哲学来源:arc42 5 (Building Block View) + C4 Model Level 3 (Component) + matklad 的轻量 ARCHITECTURE.md
6
+ > Philosophical sources: arc42 Chapter 5 (Building Block View) + C4 Model Level 3 (Component) + matklad's lightweight ARCHITECTURE.md.
7
7
 
8
8
  ---
9
9
 
10
- ## 1. 分层规则
10
+ ## 1. Layering Rules
11
11
 
12
- <!-- 这是整个架构最硬性的约束。每个层的"允许依赖什么"必须明确。 -->
12
+ <!-- This is the hardest constraint in the entire architecture. Each layer's "allowed dependencies" must be explicit. -->
13
13
 
14
14
  ```
15
15
  ┌──────────────────────────┐
16
- │ interfaces/ │ ← 用户入口(CLI / API / UI
17
- 可依赖: harness
16
+ │ interfaces/ │ ← User entry (CLI / API / UI)
17
+ May depend on: harness│
18
18
  ├──────────────────────────┤
19
- │ harness/ │ ← 通用运行外壳:编排、安全、审计、调度
20
- 可依赖: application 不包含业务规则
19
+ │ harness/ │ ← Generic runtime shell: orchestration,
20
+ May depend on: security, auditing, scheduling
21
+ │ application │ Contains no business rules
21
22
  ├──────────────────────────┤
22
- │ application/ │ ← 业务用例编排
23
- 可依赖: domain
23
+ │ application/ │ ← Business use-case orchestration
24
+ May depend on: domain
24
25
  ├──────────────────────────┤
25
- │ domain/ │ ← 纯业务对象 + 端口协议
26
- 只依赖: 标准库 不依赖任何外部实现
26
+ │ domain/ │ ← Pure business objects + port protocols
27
+ Only depends on: Depends on no external implementations
28
+ │ standard library │
27
29
  ├──────────────────────────┤
28
- │ infrastructure/ │ ← 适配器实现(数据源、外部服务)
29
- 实现 domain 的端口
30
+ │ infrastructure/ │ ← Adapter implementations (data sources,
31
+ Implements domain │ external services)
32
+ │ ports │
30
33
  └──────────────────────────┘
31
34
  ```
32
35
 
33
- **硬约束**:
34
- - domain 绝不导入 infrastructure/ interfaces/
35
- - application 只依赖 domain
36
- - harness 协调流程但不包含领域业务规则
37
- - 所有跨层通信通过 domain 定义的端口协议
36
+ **Hard Constraints**:
37
+ - domain must never import infrastructure/ or interfaces/
38
+ - application only depends on domain
39
+ - harness coordinates workflows but contains no domain business rules
40
+ - All cross-layer communication goes through port protocols defined in domain
38
41
 
39
42
  ---
40
43
 
41
- ## 2. Harness 核心组件
44
+ ## 2. Harness Core Components
42
45
 
43
46
  ### 2.1 Runner / Loop
44
47
 
45
- - **职责**:驱动一次任务从输入到完成:加载上下文、调用 application use-case、处理停止条件。
46
- - **设计决策**:
47
- - Runner 只编排,不解释领域含义为什么:保持 harness 可复用于不同业务域
48
- - 停止条件显式建模为什么:防止 agent loop 无限运行或静默半完成
49
- - **不负责**:业务规则、领域对象创建细节、外部服务实现
48
+ - **Responsibility**: Drives a task from input to completion: loading context, calling application use-cases, handling stop conditions.
49
+ - **Design Decision**:
50
+ - Runner only orchestrates, does not interpret domain meaning Rationale: keeps harness reusable across different business domains
51
+ - Stop conditions are explicitly modeled Rationale: prevents agent loops from running indefinitely or silently half-completing
52
+ - **Does NOT handle**: Business rules, domain object creation details, external service implementations
50
53
 
51
54
  ### 2.2 Permission Policy
52
55
 
53
- - **职责**:决定某个工具、文件、网络或外部动作是否允许执行。
54
- - **设计决策**:
55
- - 默认拒绝高风险动作,允许规则显式声明为什么:底座要先保证安全边界
56
- - **不负责**:判断业务动作是否正确
56
+ - **Responsibility**: Decides whether a given tool, file, network, or external action is allowed to execute.
57
+ - **Design Decision**:
58
+ - High-risk actions are denied by default, allow rules are explicitly declared Rationale: the platform must first guarantee security boundaries
59
+ - **Does NOT handle**: Judging whether a business action is correct
57
60
 
58
61
  ### 2.3 Event Bus / Audit Trail
59
62
 
60
- - **职责**:记录任务生命周期、工具调用、失败、人工审批和最终结果。
61
- - **设计决策**:
62
- - 事件追加写入,审计记录不可原地改写为什么:方便回放、排错和复盘
63
- - **不负责**:替业务系统保存最终数据
63
+ - **Responsibility**: Records task lifecycle, tool invocations, failures, human approvals, and final results.
64
+ - **Design Decision**:
65
+ - Events are append-only, audit records cannot be overwritten in place Rationale: facilitates replay, debugging, and post-mortem analysis
66
+ - **Does NOT handle**: Saving final data on behalf of business systems
64
67
 
65
68
  ### 2.4 State / Checkpoint Store
66
69
 
67
- - **职责**:保存可恢复状态、上下文摘要、任务进度和中断点。
68
- - **设计决策**:
69
- - 状态格式必须可序列化为什么:便于 replayresume、测试和迁移
70
- - **不负责**:长期业务数据库建模
70
+ - **Responsibility**: Saves recoverable state, context summaries, task progress, and interrupt points.
71
+ - **Design Decision**:
72
+ - State format must be serializable Rationale: enables replay, resume, testing, and migration
73
+ - **Does NOT handle**: Long-term business database modeling
71
74
 
72
75
  ### 2.5 Tool Registry
73
76
 
74
- - **职责**:注册可调用工具及其输入/输出契约、权限标签和错误语义。
75
- - **设计决策**:
76
- - 工具契约写清输入、输出、错误和副作用为什么:降低 agent 误用工具的概率
77
- - **不负责**:工具内部业务实现
77
+ - **Responsibility**: Registers callable tools along with their input/output contracts, permission labels, and error semantics.
78
+ - **Design Decision**:
79
+ - Tool contracts explicitly specify input, output, errors, and side effects Rationale: reduces the probability of agent tool misuse
80
+ - **Does NOT handle**: Internal business implementation of tools
78
81
 
79
82
  ---
80
83
 
81
- ## 3. 架构约束(不可协商)
84
+ ## 3. Architectural Constraints (Non-Negotiable)
82
85
 
83
- - `domain/` 只定义业务模型、业务不变量和端口协议,不导入 `harness/`、`infrastructure/` `interfaces/`。
84
- - `harness/` 可以协调流程、安全门、审计和停止条件,但不能决定业务含义。
85
- - 所有跨层外部能力都通过 `domain` 端口表达,适配器实现放在 `infrastructure/`。
86
- - 拒绝和失败必须能被测试或在 feature doc 中写明人工验证。
87
- - 审计事件追加记录,不原地改写。
86
+ - `domain/` only defines business models, business invariants, and port protocols; does not import `harness/`, `infrastructure/`, or `interfaces/`.
87
+ - `harness/` may orchestrate workflows, security gates, auditing, and stop conditions, but must not determine business meaning.
88
+ - All cross-layer external capabilities are expressed through `domain` ports; adapter implementations live in `infrastructure/`.
89
+ - Rejections and failures must be testable or documented with manual verification steps in the feature doc.
90
+ - Audit events are append-only, never overwritten in place.
@@ -0,0 +1,93 @@
1
+ # Context Loading Protocol
2
+
3
+ Use when context is growing, subagents are needed, or an agent is unsure which harness doc applies.
4
+
5
+ ## Routing Authority
6
+
7
+ `docs/README.md` is the primary router. This file is a secondary context-splitting protocol for subagents and long tasks.
8
+
9
+ If this file and `docs/README.md` disagree, follow `docs/README.md`, record the assumption in `docs/harness/PLAN.md`, and update this file later.
10
+
11
+ ## Main Context
12
+
13
+ Always keep:
14
+
15
+ - `CLAUDE.md`
16
+ - `MEMORY.md`
17
+ - `docs/README.md`
18
+ - `docs/harness/PLAN.md` when active
19
+ - current feature doc when active
20
+
21
+ Load other docs only by trigger.
22
+
23
+ ## Trigger Matrix
24
+
25
+ | Trigger | Load |
26
+ | --- | --- |
27
+ | idea, scope, MVP | `docs/harness/lifecycle.md`, `docs/research/PRD.md` |
28
+ | research, competitors, stack choice | `docs/research/README.md`, `docs/research/research-results.md` |
29
+ | official docs, API, SDK, version, limits | `docs/research/README.md`, `docs/harness/architecture.md`, `docs/domain/ports.md` as needed |
30
+ | layer, dependency, module boundary | `docs/harness/architecture.md`, `docs/domain/ports.md` |
31
+ | task split, owner, write set | `docs/harness/PLAN.md`, `docs/harness/agent-workflow.md` |
32
+ | parallel agents, dispatch, worktree decision | `docs/harness/dispatch.md`, `docs/harness/PLAN.md` |
33
+ | event, retry, failure path | `docs/harness/data-flow.md` |
34
+ | status, transition, resume | `docs/harness/state-machines.md` |
35
+ | subagent spawn | this file plus the role pack below |
36
+
37
+ ## Subagent Packs
38
+
39
+ Explorer Pass:
40
+ - inject: question, read boundary, relevant docs
41
+ - forbid: writes
42
+ - return: files found, facts, risks, suggested tests
43
+
44
+ Planner:
45
+ - inject: user goal, lifecycle phase, PRD or PLAN section, dispatch constraints
46
+ - forbid: production code
47
+ - return: tasks, dependencies, read/write sets, dispatch table, gates, open questions
48
+
49
+ Researcher:
50
+ - inject: question, decision needed, source boundaries, tool options
51
+ - forbid: production code
52
+ - return: sources, adopted/rejected/watch decisions, risks, research-results.md patch
53
+
54
+ Docs Researcher:
55
+ - inject: library/API/config, implementation question, version/date constraints
56
+ - forbid: production code
57
+ - return: official links, constraints, errors, examples, affected docs
58
+
59
+ Architect:
60
+ - inject: PRD, current architecture, ports
61
+ - forbid: implementation
62
+ - return: boundary decision, affected docs, risks
63
+
64
+ Test Writer:
65
+ - inject: acceptance criteria, feature doc, test write set
66
+ - forbid: production code
67
+ - return: failing tests and test intent
68
+
69
+ Implementer:
70
+ - inject: task, tests, allowed write set, forbidden scope
71
+ - forbid: unrelated refactor and test loosening
72
+ - return: changed files and implementation notes
73
+
74
+ Reviewer:
75
+ - inject: diff, acceptance criteria, architecture docs
76
+ - forbid: writes
77
+ - return: findings by severity, missing tests, boundary issues
78
+
79
+ Debugger:
80
+ - inject: failing command, error output, related files
81
+ - forbid: broad rewrites
82
+ - return: root cause, fix, proof
83
+
84
+ Verifier:
85
+ - inject: verification commands and acceptance criteria
86
+ - forbid: code changes
87
+ - return: commands run, results, residual risk
88
+
89
+ ## Handoff Rule
90
+
91
+ Only the subagent summary enters main context. If details are needed, load the named files directly instead of replaying the subagent conversation.
92
+
93
+ Use the handoff format in [dispatch.md](dispatch.md) for every dispatched agent.
@@ -1,23 +1,23 @@
1
- # 数据流 — {{projectName}}
1
+ # Data Flow — {{projectName}}
2
2
 
3
- > **职责**:定义每个事件/请求的完整生命周期——正常路径 + 所有失败分支。
4
- > **这是整个 docs 里最重要的文件**——AI 实现时最常编造的就是失败路径行为。写清楚就不会。
3
+ > **Purpose**: Define the complete lifecycle of each event/request — happy path + all failure branches.
4
+ > **This is the most important file in the entire docs folder** — what AI most often invents during implementation is failure-path behavior. Write it clearly and it won't.
5
5
  >
6
- > 哲学来源:EventCatalog 模式 + arc42 6 (Runtime View)
6
+ > Philosophy source: EventCatalog pattern + arc42 Chapter 6 (Runtime View).
7
7
 
8
8
  ---
9
9
 
10
- ## 1. 事件目录
10
+ ## 1. Event Catalog
11
11
 
12
- | 事件类型 | 生产者 | 消费者 | Payload 关键字段 | 投递语义 | 排序要求 |
12
+ | Event Type | Producer | Consumer | Payload Key Fields | Delivery Semantics | Ordering Requirements |
13
13
  | --- | --- | --- | --- | --- | --- |
14
14
  | `{{EVENT_1}}` | `{{PRODUCER}}` | `{{CONSUMERS}}` | `{{KEY_FIELDS}}` | {{SEMANTICS}} | {{ORDERING}} |
15
15
 
16
16
  ---
17
17
 
18
- ## 2. 核心流程
18
+ ## 2. Core Flows
19
19
 
20
- ### 2.1 正常路径
20
+ ### 2.1 Happy Path
21
21
 
22
22
  ```mermaid
23
23
  sequenceDiagram
@@ -37,23 +37,23 @@ sequenceDiagram
37
37
  Runner-->>Caller: {{FINAL_RESULT}}
38
38
  ```
39
39
 
40
- ### 2.2 失败路径
40
+ ### 2.2 Failure Paths
41
41
 
42
- 每个失败点必须写清:
43
- - **触发条件**
44
- - **系统行为**
45
- - **事件发布**
46
- - **调用方感知**
47
- - **恢复方式**
42
+ Each failure point must clearly document:
43
+ - **Trigger condition**
44
+ - **System behavior**
45
+ - **Event publishing**
46
+ - **Caller perception**
47
+ - **Recovery method**
48
48
 
49
49
  ---
50
50
 
51
- ## 3. 错误处理约定
51
+ ## 3. Error Handling Conventions
52
52
 
53
- - **可重试错误**:{{POLICY}}
54
- - **不可重试错误**:{{POLICY}}
55
- - **静默忽略**:{{POLICY}}
53
+ - **Retryable errors**: {{POLICY}}
54
+ - **Non-retryable errors**: {{POLICY}}
55
+ - **Silent ignore**: {{POLICY}}
56
56
 
57
57
  ---
58
58
 
59
- > **提示**:当前 data-flow.md 是空模板。请按项目实际流程填写。格式参考 ECC 仓库的实际项目示例。
59
+ > **Note**: This data-flow.md is currently an empty template. Fill it in according to your project's actual flows. For format reference, see real project examples in the ECC repository.
@@ -0,0 +1,82 @@
1
+ # Dispatch Protocol
2
+
3
+ Purpose: coordinate a small set of subagents without building a scheduler.
4
+
5
+ Use when work needs parallel reading, independent review, cross-layer analysis, or more than one bounded implementation pass.
6
+
7
+ ## Principles
8
+
9
+ - Main agent owns the final decision, integration, and verification.
10
+ - Prefer three or fewer active agents.
11
+ - Read-only agents may run in parallel.
12
+ - Writing agents run serially unless write sets are disjoint.
13
+ - Use a worktree when two agents may touch overlapping files or long-running branches.
14
+ - Only summaries enter main context. Load named files directly when details are needed.
15
+
16
+ ## Dispatch Loop
17
+
18
+ ```text
19
+ Goal
20
+ -> Fill PLAN tasks and Parallel Dispatch
21
+ -> Run parallel read-only agents
22
+ -> Main agent integrates findings
23
+ -> Test Writer defines failing test or manual check
24
+ -> Implementer makes bounded change
25
+ -> Reviewer checks diff
26
+ -> Verifier records evidence
27
+ -> Main agent updates PLAN and closes or iterates
28
+ ```
29
+
30
+ ## Modes
31
+
32
+ | Mode | Use When | Constraint |
33
+ | --- | --- | --- |
34
+ | Parallel Read | research, exploration, architecture review, docs/API check | no writes |
35
+ | Serial Write | tests, implementation, docs sync | one writer at a time |
36
+ | Isolated Worktree | overlapping write sets or competing approaches | merge only after review |
37
+
38
+ ## Common Agents
39
+
40
+ | Agent | Mode | Purpose |
41
+ | --- | --- | --- |
42
+ | `planner` | Parallel Read | split goal into tasks, dependencies, write sets |
43
+ | Explorer Pass | Parallel Read | bounded read-only exploration when no dedicated agent is needed |
44
+ | `researcher` | Parallel Read | product, market, ecosystem, dependency research |
45
+ | `docs-researcher` | Parallel Read | official docs, API, SDK, version, limits |
46
+ | `architect` | Parallel Read | layer boundaries, ports, data flow, state impact |
47
+ | `test-writer` | Serial Write | failing test or manual verification plan |
48
+ | `implementer` | Serial Write | minimal change inside declared write set |
49
+ | `debugger` | Serial Write | smallest fix for a reproduced failure |
50
+ | `reviewer` | Parallel Read | diff review, risks, missing tests |
51
+ | `verifier` | Parallel Read | run checks and record evidence |
52
+
53
+ ## Dispatch Rules
54
+
55
+ - Every dispatch row needs task, agent, mode, read set, write set, dependency, output, and status.
56
+ - A write set of `none` means read-only.
57
+ - If two write sets overlap, do not run those agents in parallel.
58
+ - If an agent returns uncertainty, mark the row `Blocked` or add a follow-up row.
59
+ - If docs, tests, and code disagree, stop implementation and record the conflict in `PLAN.md`.
60
+
61
+ ## Handoff Format
62
+
63
+ Subagents return summaries in this shape:
64
+
65
+ ```text
66
+ Agent:
67
+ Task:
68
+ Mode:
69
+ Files read:
70
+ Files changed:
71
+ Findings:
72
+ Evidence:
73
+ Risks:
74
+ Next:
75
+ PLAN patch:
76
+ ```
77
+
78
+ Use `Files changed: none` for read-only agents. Use `PLAN patch: none` when no state update is needed.
79
+
80
+ ## Statuses
81
+
82
+ Allowed dispatch statuses: Pending / In Progress / Returned / Integrated / Blocked / Verified.
@@ -0,0 +1,67 @@
1
+ # Extension Contract
2
+
3
+ Purpose: keep stack-specific agents, skills, rules, and hooks compatible with this harness.
4
+
5
+ Use during setup whenever adding assets from ECC, SuperClaude, toolboxes, or local project conventions.
6
+
7
+ ## Agent Contract
8
+
9
+ Every added agent must have frontmatter:
10
+
11
+ ```yaml
12
+ ---
13
+ name: stack-agent-name
14
+ description: Use when ...
15
+ tools: Read, Grep, Glob
16
+ model: sonnet
17
+ skills: harness-context
18
+ ---
19
+ ```
20
+
21
+ Choose one harness skill:
22
+
23
+ | Agent Type | Skill |
24
+ | --- | --- |
25
+ | research, docs, API lookup | `harness-research` |
26
+ | planning, architecture, context split | `harness-context` |
27
+ | tests, implementation, debugging, review, verification | `harness-build-loop` |
28
+
29
+ Agent body must state:
30
+
31
+ - load first
32
+ - inputs required
33
+ - allowed write set or read-only
34
+ - forbidden scope
35
+ - verification or evidence
36
+ - return format from [dispatch.md](dispatch.md)
37
+
38
+ ## Skill Contract
39
+
40
+ Every added skill must state:
41
+
42
+ - when to use
43
+ - docs to load
44
+ - required inputs
45
+ - allowed writes
46
+ - output format
47
+ - whether to update `docs/harness/PLAN.md`
48
+ - whether to use [dispatch.md](dispatch.md)
49
+
50
+ Skills should extend the harness. They should not replace `docs/README.md`, `PLAN.md`, `context-loading.md`, `dispatch.md`, or `agent-workflow.md`.
51
+
52
+ ## Rules
53
+
54
+ - Do not add broad agents that can write anywhere.
55
+ - Do not add agents whose role overlaps an existing common agent without naming the difference.
56
+ - Do not add tools that bypass project permissions or user approval.
57
+ - Do not run stack-specific writing agents in parallel unless write sets are disjoint.
58
+ - If an added asset conflicts with this harness, adapt the asset instead of changing the core contract.
59
+
60
+ ## Registration
61
+
62
+ After adding assets:
63
+
64
+ - list agents in `MEMORY.md#Agents`
65
+ - list skills in `MEMORY.md#Skills`
66
+ - update `docs/harness/PLAN.md` when the asset affects current work
67
+ - run `node scripts/validate-harness.mjs`