ai-dev-harness 0.1.0 → 0.1.1

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 (32) hide show
  1. package/COLLEAGUE_TRIAL_GUIDE.md +147 -0
  2. package/README.md +116 -52
  3. package/dist/agent.js +44 -31
  4. package/dist/cli.js +65 -42
  5. package/dist/config.js +79 -8
  6. package/dist/context.js +53 -21
  7. package/dist/init.js +8 -20
  8. package/dist/integration.js +22 -91
  9. package/dist/mcp.js +29 -112
  10. package/dist/runPaths.js +1 -0
  11. package/dist/summarize.js +42 -39
  12. package/dist/templates.js +39 -215
  13. package/package.json +3 -1
  14. package/scripts/read-evidence.ps1 +9 -3
  15. package/scripts/run-harness.ps1 +8 -5
  16. package/templates/default-project/AGENTS.md +9 -0
  17. package/templates/default-project/SKILLS.md +13 -0
  18. package/templates/default-project/TOOLS.md +8 -0
  19. package/templates/default-project/skills/add_feature/SKILL.md +34 -0
  20. package/templates/default-project/skills/add_feature/context.yaml +30 -0
  21. package/templates/default-project/skills/add_feature/verify.yaml +2 -0
  22. package/templates/default-project/skills/fix_bug/SKILL.md +45 -0
  23. package/templates/default-project/skills/fix_bug/context.yaml +30 -0
  24. package/templates/default-project/skills/fix_bug/verify.yaml +2 -0
  25. package/templates/default-project/skills/update_docs/SKILL.md +28 -0
  26. package/templates/default-project/skills/update_docs/context.yaml +26 -0
  27. package/templates/default-project/skills/update_docs/verify.yaml +2 -0
  28. package/templates/default-project/skills/write_tests/SKILL.md +30 -0
  29. package/templates/default-project/skills/write_tests/context.yaml +29 -0
  30. package/templates/default-project/skills/write_tests/verify.yaml +2 -0
  31. package/templates/integrations/claude/SKILL.md +79 -0
  32. package/templates/integrations/codex/AGENTS_BLOCK.md +51 -0
package/dist/templates.js CHANGED
@@ -1,217 +1,41 @@
1
+ import path from "node:path";
2
+ import { readdir, readFile } from "node:fs/promises";
3
+ import { fileURLToPath } from "node:url";
1
4
  import { defaultConfigYaml } from "./config.js";
2
- export const rootTemplates = {
3
- "harness.yaml": defaultConfigYaml(),
4
- "AGENTS.md": `# Project Agent Rules
5
-
6
- - Work inside this Git repository only.
7
- - Prefer small, reviewable changes.
8
- - Do not modify generated or dependency directories.
9
- - Always explain impact, risk, verification, and follow-up knowledge updates.
10
- - Before changing code, state assumptions, affected areas, and a minimal plan.
11
- - If required context is missing or confidence is low, stop and report what is missing instead of guessing.
12
- - Do not perform broad refactors, formatting-only sweeps, dependency upgrades, or unrelated cleanup unless the task explicitly asks for them.
13
- `,
14
- "TOOLS.md": `# Tool Rules
15
-
16
- - Codex and Claude Code are execution agents.
17
- - CodeGraph MCP provides code impact context.
18
- - Knowledge Graph MCP provides ADR, module, API, runbook, and decision context.
19
- - Verification commands are defined in harness.yaml and skill verify.yaml files.
20
- - Harness run evidence is stored in runs/<run_id>/ and must be treated as the audit record.
21
- - Knowledge Graph is read-only in v1. Write suggestions to persist_suggestions.md only.
22
- `,
23
- "SKILLS.md": `# Skill Index
24
-
25
- - fix_bug: diagnose and fix a defect with tests when possible.
26
- - add_feature: implement a scoped feature with verification.
27
- - write_tests: add or improve tests for existing behavior.
28
- - update_docs: update project documentation and knowledge suggestions.
29
-
30
- Every skill follows the same execution contract:
31
-
32
- 1. Analysis Contract: identify assumptions, affected files/modules, likely risks, and the smallest viable plan.
33
- 2. Execution Contract: make only task-relevant changes and avoid opportunistic refactors.
34
- 3. Verification Contract: run or defer verification with explicit reasons.
35
- 4. Report Contract: explain root cause or intent, changed files, verification, residual risk, and knowledge suggestions.
36
- `
37
- };
38
- const baseContext = `queries:
39
- - related files
40
- - symbols
41
- - call graph
42
- - dependencies
43
- - impact analysis
44
- fallbackInclude:
45
- - README.md
46
- - src
47
- `;
48
- const defaultVerify = `- name: git status
49
- command: git status --short
50
- `;
51
- export const skillTemplates = {
52
- fix_bug: {
53
- "SKILL.md": `# fix_bug
54
-
55
- ## Goal
56
- Diagnose and fix a defect with the smallest safe code change.
57
-
58
- ## Inputs
59
- - Task text or issue description.
60
- - CodeGraph impact context.
61
- - Knowledge Graph related decisions, module notes, APIs, and runbooks.
62
-
63
- ## Outputs
64
- - Code change.
65
- - Test or verification result.
66
- - Summary with root cause, impact, risk, and follow-up suggestions.
67
-
68
- ## Analysis Contract
69
- - Restate the observed defect and expected behavior.
70
- - Identify the likely root cause and the code path involved.
71
- - List assumptions and confidence level before editing.
72
- - Use CodeGraph impact context to avoid missing callers or dependent modules.
73
- - Use Knowledge Graph decisions and runbooks to avoid violating historical constraints.
74
-
75
- ## Execution Contract
76
- - Make the smallest task-relevant change.
77
- - Prefer adding or updating a regression test when feasible.
78
- - Do not rewrite unrelated code, rename public APIs, change formatting broadly, or upgrade dependencies.
79
- - If root cause is unclear after inspection, stop and report missing evidence instead of guessing.
80
-
81
- ## Verification Contract
82
- - Run the configured verification commands through Harness.
83
- - If manual or targeted verification is needed, describe the exact command or scenario.
84
- - Record any verification that could not be run and why.
85
-
86
- ## Report Contract
87
- - Root cause.
88
- - Files changed.
89
- - Why the fix is safe.
90
- - Verification result.
91
- - Residual risk.
92
- - Knowledge or runbook update suggestions.
93
-
94
- ## Acceptance
95
- - The defect is explained.
96
- - The change is limited to the affected area.
97
- - Relevant verification commands pass or failures are recorded.
98
- `,
99
- "verify.yaml": defaultVerify,
100
- "context.yaml": baseContext
101
- },
102
- add_feature: {
103
- "SKILL.md": `# add_feature
104
-
105
- ## Goal
106
- Implement a scoped feature using existing project patterns.
107
-
108
- ## Analysis Contract
109
- - Restate the feature intent and non-goals.
110
- - Identify affected modules, public interfaces, data flows, and compatibility risks.
111
- - Check CodeGraph context for callers, dependencies, and likely integration points.
112
- - Check Knowledge Graph context for ADRs, API contracts, and previous decisions.
113
-
114
- ## Execution Contract
115
- - Implement the smallest coherent slice that satisfies the task.
116
- - Follow existing patterns before introducing new abstractions.
117
- - Do not change unrelated behavior or broaden scope.
118
- - Preserve backward compatibility unless the task explicitly allows breaking changes.
119
-
120
- ## Verification Contract
121
- - Add or update tests when behavior changes.
122
- - Run configured verification commands through Harness.
123
- - Record unverified scenarios and reasons.
124
-
125
- ## Report Contract
126
- - Feature behavior implemented.
127
- - Files changed.
128
- - Compatibility notes.
129
- - Verification result.
130
- - Residual risk.
131
- - Documentation or knowledge suggestions.
132
-
133
- ## Outputs
134
- - Code change.
135
- - Tests or verification.
136
- - Documentation and knowledge suggestions when behavior changes.
137
- `,
138
- "verify.yaml": defaultVerify,
139
- "context.yaml": baseContext
140
- },
141
- write_tests: {
142
- "SKILL.md": `# write_tests
143
-
144
- ## Goal
145
- Add or improve tests for existing behavior without changing production behavior unless required.
146
-
147
- ## Analysis Contract
148
- - Identify the behavior under test and the risk it protects.
149
- - Locate existing test patterns, fixtures, and helper APIs.
150
- - Check CodeGraph context for affected code paths.
151
- - Avoid inventing behavior not supported by source code or knowledge context.
152
-
153
- ## Execution Contract
154
- - Prefer focused tests over broad snapshot or brittle integration tests.
155
- - Do not change production code unless the existing code is untestable and the change is minimal.
156
- - Keep fixtures deterministic and local to the test where possible.
157
-
158
- ## Verification Contract
159
- - Run the relevant test command or configured Harness verification.
160
- - If the full suite is too expensive, document the targeted command and why.
161
-
162
- ## Report Contract
163
- - Scenarios covered.
164
- - Files changed.
165
- - Verification result.
166
- - Remaining uncovered risks.
167
-
168
- ## Outputs
169
- - Test files or fixture updates.
170
- - Verification result.
171
- - Summary of covered scenarios.
172
- `,
173
- "verify.yaml": defaultVerify,
174
- "context.yaml": baseContext
175
- },
176
- update_docs: {
177
- "SKILL.md": `# update_docs
178
-
179
- ## Goal
180
- Update project documentation and propose knowledge graph additions.
181
-
182
- ## Analysis Contract
183
- - Identify the audience and purpose of the documentation update.
184
- - Cross-check docs against code, CodeGraph context, and Knowledge Graph records.
185
- - Distinguish confirmed facts from inferred guidance.
186
-
187
- ## Execution Contract
188
- - Update only documentation or knowledge suggestion artifacts unless explicitly asked to change code.
189
- - Keep docs concise, operational, and linked to actual project behavior.
190
- - Do not write directly to Knowledge Graph in v1.
191
-
192
- ## Verification Contract
193
- - Check links, commands, paths, and filenames mentioned in the docs.
194
- - Run configured verification when docs affect generated artifacts or examples.
195
-
196
- ## Report Contract
197
- - Docs changed.
198
- - Source of truth used.
199
- - Verification result.
200
- - Knowledge Graph suggestions.
201
-
202
- ## Outputs
203
- - Documentation changes.
204
- - Persist suggestions for ADR, module notes, runbooks, or decisions.
205
- `,
206
- "verify.yaml": defaultVerify,
207
- "context.yaml": `queries:
208
- - related docs
209
- - ADR
210
- - module notes
211
- - API docs
212
- fallbackInclude:
213
- - README.md
214
- - docs
215
- `
5
+ import { pathExists } from "./utils.js";
6
+ export function packageRootFromHere() {
7
+ return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
8
+ }
9
+ export function templateRoot(packageRoot = packageRootFromHere()) {
10
+ return path.join(packageRoot, "templates");
11
+ }
12
+ export async function readTemplateFile(relPath, packageRoot = packageRootFromHere()) {
13
+ return readFile(path.join(templateRoot(packageRoot), relPath), "utf8");
14
+ }
15
+ export function renderTemplate(content, vars) {
16
+ return Object.entries(vars).reduce((next, [key, value]) => next.replaceAll(`{{${key}}}`, value), content);
17
+ }
18
+ export async function readTemplateTree(relDir, packageRoot = packageRootFromHere()) {
19
+ const root = path.join(templateRoot(packageRoot), relDir);
20
+ const files = [];
21
+ async function walk(absDir, relBase) {
22
+ const entries = await readdir(absDir, { withFileTypes: true });
23
+ for (const entry of entries) {
24
+ const abs = path.join(absDir, entry.name);
25
+ const rel = path.join(relBase, entry.name);
26
+ if (entry.isDirectory()) {
27
+ await walk(abs, rel);
28
+ }
29
+ else {
30
+ files.push({ relPath: rel, content: await readFile(abs, "utf8") });
31
+ }
32
+ }
216
33
  }
217
- };
34
+ if (await pathExists(root))
35
+ await walk(root, "");
36
+ return files;
37
+ }
38
+ export async function defaultProjectTemplates(packageRoot = packageRootFromHere()) {
39
+ const files = await readTemplateTree("default-project", packageRoot);
40
+ return [{ relPath: "harness.yaml", content: defaultConfigYaml() }, ...files];
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-dev-harness",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Auditable AI development harness for Codex and Claude Code.",
5
5
  "license": "MIT",
6
6
  "keywords": [
@@ -21,7 +21,9 @@
21
21
  "!dist/**/*.test.js",
22
22
  "!dist/testSupport.js",
23
23
  "scripts/",
24
+ "templates/",
24
25
  "README.md",
26
+ "COLLEAGUE_TRIAL_GUIDE.md",
25
27
  "package.json"
26
28
  ],
27
29
  "scripts": {
@@ -14,10 +14,11 @@ $runPath = if (Test-Path -LiteralPath $Run) {
14
14
  Resolve-Path -LiteralPath (Join-Path $repoPath "runs\$Run")
15
15
  }
16
16
 
17
- Write-Host "[harness-skill] evidence: $runPath"
17
+ Write-Host "[harness-skill] 证据目录: $runPath"
18
18
 
19
19
  $summary = Join-Path $runPath "summary.md"
20
20
  $verify = Join-Path $runPath "verify.json"
21
+ $contract = Join-Path $runPath "agent_contract.json"
21
22
  $audit = Join-Path $runPath "audit.jsonl"
22
23
 
23
24
  if (Test-Path -LiteralPath $summary) {
@@ -30,7 +31,12 @@ if (Test-Path -LiteralPath $verify) {
30
31
  Get-Content -LiteralPath $verify
31
32
  }
32
33
 
34
+ if (Test-Path -LiteralPath $contract) {
35
+ Write-Host "`n--- agent_contract.json ---"
36
+ Get-Content -LiteralPath $contract
37
+ }
38
+
33
39
  if (Test-Path -LiteralPath $audit) {
34
- Write-Host "`n--- audit degraded/errors ---"
35
- Select-String -LiteralPath $audit -Pattern "degraded|failed|error|run_finished" | ForEach-Object { $_.Line }
40
+ Write-Host "`n--- 审计失败/错误 ---"
41
+ Select-String -LiteralPath $audit -Pattern "failed|error|run_finished" | ForEach-Object { $_.Line }
36
42
  }
@@ -19,7 +19,11 @@ $ErrorActionPreference = "Stop"
19
19
 
20
20
  $repoPath = Resolve-Path -LiteralPath $Repo
21
21
  $harnessYaml = Join-Path $repoPath "harness.yaml"
22
- $cliPath = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..\dist\cli.js")
22
+ $cliPath = '{{HARNESS_CLI_PATH}}'
23
+
24
+ if ($cliPath -like '{{*}}') {
25
+ $cliPath = Resolve-Path -LiteralPath (Join-Path $PSScriptRoot "..\dist\cli.js")
26
+ }
23
27
 
24
28
  Write-Host "[harness-skill] repo: $repoPath"
25
29
  Write-Host "[harness-skill] checking config: $harnessYaml"
@@ -33,8 +37,7 @@ if ($LASTEXITCODE -ne 0) {
33
37
  Write-Error "$repoPath is not a Git repository. AI Dev Harness run requires a business Git repository."
34
38
  }
35
39
 
36
- $argsList = @(
37
- $cliPath,
40
+ $argList = @(
38
41
  "run",
39
42
  "--task",
40
43
  $Task,
@@ -45,9 +48,9 @@ $argsList = @(
45
48
  )
46
49
 
47
50
  if ($Live) {
48
- $argsList += "--live"
51
+ $argList += "--live"
49
52
  }
50
53
 
51
54
  Write-Host "[harness-skill] starting harness: $Skill via $Agent"
52
- node @argsList
55
+ node $cliPath @argList
53
56
  exit $LASTEXITCODE
@@ -0,0 +1,9 @@
1
+ # Project Agent Rules
2
+
3
+ - Work inside this Git repository only.
4
+ - Prefer small, reviewable changes.
5
+ - Do not modify generated or dependency directories.
6
+ - Always explain impact, risk, verification, and follow-up knowledge updates.
7
+ - Before changing code, state assumptions, affected areas, and a minimal plan.
8
+ - If required context is missing or confidence is low, stop and report what is missing instead of guessing.
9
+ - Do not perform broad refactors, formatting-only sweeps, dependency upgrades, or unrelated cleanup unless the task explicitly asks for them.
@@ -0,0 +1,13 @@
1
+ # Skill Index
2
+
3
+ - fix_bug: diagnose and fix a defect with tests when possible.
4
+ - add_feature: implement a scoped feature with verification.
5
+ - write_tests: add or improve tests for existing behavior.
6
+ - update_docs: update project documentation and knowledge suggestions.
7
+
8
+ Every skill follows the same execution contract:
9
+
10
+ 1. Analysis Contract: identify assumptions, affected files/modules, likely risks, and the smallest viable plan.
11
+ 2. Execution Contract: make only task-relevant changes and avoid opportunistic refactors.
12
+ 3. Verification Contract: run or defer verification with explicit reasons.
13
+ 4. Report Contract: explain root cause or intent, changed files, verification, residual risk, and knowledge suggestions.
@@ -0,0 +1,8 @@
1
+ # Tool Rules
2
+
3
+ - Codex and Claude Code are execution agents.
4
+ - CodeGraph MCP is used by Claude/Codex for code impact context.
5
+ - Knowledge Graph MCP is used by Claude/Codex for ADR, module, API, runbook, and decision context.
6
+ - Verification commands are defined in harness.yaml and skill verify.yaml files.
7
+ - Harness run evidence is stored in runs/<run_id>/ and must be treated as the audit record.
8
+ - Knowledge Graph is read-only in v1. Write suggestions to persist_suggestions.md only.
@@ -0,0 +1,34 @@
1
+ # add_feature
2
+
3
+ ## Goal
4
+ 基于现有项目模式实现范围明确的功能。
5
+
6
+ ## Analysis Contract
7
+ - 复述功能意图和非目标。
8
+ - 识别受影响模块、公共接口、数据流和兼容性风险。
9
+ - 使用 CodeGraph 检查调用方、依赖和集成点。
10
+ - 使用 Knowledge Graph 检查 ADR、接口契约和历史决策。
11
+
12
+ ## Execution Contract
13
+ - 实现满足任务的最小完整切片。
14
+ - 优先遵循现有模式,再考虑新增抽象。
15
+ - 不改变无关行为,不扩大范围。
16
+ - 除非任务明确允许破坏性变更,否则保持向后兼容。
17
+
18
+ ## Verification Contract
19
+ - 行为变化时添加或更新测试。
20
+ - 通过 Harness 运行配置的验证命令。
21
+ - 记录未验证场景和原因。
22
+
23
+ ## Report Contract
24
+ - 已实现的功能行为。
25
+ - 修改文件。
26
+ - 兼容性说明。
27
+ - 验证结果。
28
+ - 残余风险。
29
+ - 文档或知识沉淀建议。
30
+
31
+ ## Outputs
32
+ - 代码变更。
33
+ - 测试或验证。
34
+ - 行为变化时的文档和知识沉淀建议。
@@ -0,0 +1,30 @@
1
+ queries:
2
+ - related files
3
+ - symbols
4
+ - call graph
5
+ - dependencies
6
+ - impact analysis
7
+ mcp_preflight:
8
+ codegraph:
9
+ required: true
10
+ ask_for:
11
+ - related_files
12
+ - extension_points
13
+ - dependent_modules
14
+ - public_interfaces
15
+ - impact_scope
16
+ knowledgeGraph:
17
+ required: true
18
+ ask_for:
19
+ - product_decisions
20
+ - adr
21
+ - api_notes
22
+ - module_notes
23
+ - rollout_notes
24
+ stop_conditions:
25
+ - requirement is ambiguous
26
+ - public interface change is needed but not requested
27
+ - impact scope cannot be determined
28
+ fallbackInclude:
29
+ - README.md
30
+ - src
@@ -0,0 +1,2 @@
1
+ - name: git status
2
+ command: git status --short
@@ -0,0 +1,45 @@
1
+ # fix_bug
2
+
3
+ ## Goal
4
+ 用最小安全变更定位并修复缺陷。
5
+
6
+ ## Inputs
7
+ - 任务描述或 Issue。
8
+ - CodeGraph 影响范围上下文。
9
+ - Knowledge Graph 中的决策、模块说明、接口说明和运行手册。
10
+
11
+ ## Outputs
12
+ - 代码变更。
13
+ - 测试或验证结果。
14
+ - 包含根因、影响、风险和后续建议的总结。
15
+
16
+ ## Analysis Contract
17
+ - 复述观察到的缺陷和期望行为。
18
+ - 识别可能根因和涉及的代码路径。
19
+ - 修改前列出假设和信心等级。
20
+ - 使用 CodeGraph 影响范围,避免遗漏调用方或依赖模块。
21
+ - 使用 Knowledge Graph 决策和 runbook,避免违背历史约束。
22
+
23
+ ## Execution Contract
24
+ - 做和任务相关的最小变更。
25
+ - 可行时添加或更新回归测试。
26
+ - 不重写无关代码,不重命名公共 API,不做大范围格式化,不升级依赖。
27
+ - 如果根因不清楚,停止并报告缺失证据,不要猜。
28
+
29
+ ## Verification Contract
30
+ - 通过 Harness 运行配置的验证命令。
31
+ - 如需手动或定向验证,说明确切命令或场景。
32
+ - 记录无法执行的验证及原因。
33
+
34
+ ## Report Contract
35
+ - 根因。
36
+ - 修改文件。
37
+ - 为什么这个修复是安全的。
38
+ - 验证结果。
39
+ - 残余风险。
40
+ - 知识库或 runbook 更新建议。
41
+
42
+ ## Acceptance
43
+ - 缺陷被解释清楚。
44
+ - 变更限定在受影响区域。
45
+ - 相关验证命令通过,或失败原因被记录。
@@ -0,0 +1,30 @@
1
+ queries:
2
+ - related files
3
+ - symbols
4
+ - call graph
5
+ - dependencies
6
+ - impact analysis
7
+ mcp_preflight:
8
+ codegraph:
9
+ required: true
10
+ ask_for:
11
+ - related_files
12
+ - related_symbols
13
+ - callers
14
+ - dependencies
15
+ - impact_scope
16
+ knowledgeGraph:
17
+ required: true
18
+ ask_for:
19
+ - adr
20
+ - module_notes
21
+ - api_notes
22
+ - runbooks
23
+ - historical_decisions
24
+ stop_conditions:
25
+ - root cause is unclear
26
+ - impact scope cannot be determined
27
+ - verification path is missing
28
+ fallbackInclude:
29
+ - README.md
30
+ - src
@@ -0,0 +1,2 @@
1
+ - name: git status
2
+ command: git status --short
@@ -0,0 +1,28 @@
1
+ # update_docs
2
+
3
+ ## Goal
4
+ 更新项目文档,并提出 Knowledge Graph 沉淀建议。
5
+
6
+ ## Analysis Contract
7
+ - 识别文档更新的读者和目的。
8
+ - 对照代码、CodeGraph 上下文和 Knowledge Graph 记录校验文档。
9
+ - 区分已确认事实和推断建议。
10
+
11
+ ## Execution Contract
12
+ - 除非明确要求改代码,否则只更新文档或知识建议产物。
13
+ - 文档应简洁、可操作,并和真实项目行为一致。
14
+ - v1 不直接写入 Knowledge Graph。
15
+
16
+ ## Verification Contract
17
+ - 检查文档中的链接、命令、路径和文件名。
18
+ - 如果文档影响生成产物或示例,运行配置的验证命令。
19
+
20
+ ## Report Contract
21
+ - 修改的文档。
22
+ - 使用的事实来源。
23
+ - 验证结果。
24
+ - Knowledge Graph 沉淀建议。
25
+
26
+ ## Outputs
27
+ - 文档变更。
28
+ - ADR、模块说明、runbook 或决策记录的沉淀建议。
@@ -0,0 +1,26 @@
1
+ queries:
2
+ - related docs
3
+ - ADR
4
+ - module notes
5
+ - API docs
6
+ mcp_preflight:
7
+ codegraph:
8
+ required: false
9
+ ask_for:
10
+ - related_files
11
+ - public_interfaces
12
+ - ownership
13
+ knowledgeGraph:
14
+ required: true
15
+ ask_for:
16
+ - adr
17
+ - module_notes
18
+ - api_notes
19
+ - runbooks
20
+ - stale_docs
21
+ stop_conditions:
22
+ - documentation target is unclear
23
+ - source of truth cannot be identified
24
+ fallbackInclude:
25
+ - README.md
26
+ - docs
@@ -0,0 +1,2 @@
1
+ - name: git status
2
+ command: git status --short
@@ -0,0 +1,30 @@
1
+ # write_tests
2
+
3
+ ## Goal
4
+ 为已有行为添加或改进测试,除非必要,不改变生产行为。
5
+
6
+ ## Analysis Contract
7
+ - 识别被测行为以及它覆盖的风险。
8
+ - 找到现有测试模式、fixture 和 helper API。
9
+ - 使用 CodeGraph 检查受影响代码路径。
10
+ - 不发明源码或知识上下文不支持的行为。
11
+
12
+ ## Execution Contract
13
+ - 优先编写聚焦测试,避免脆弱的大快照或过宽集成测试。
14
+ - 除非现有代码不可测试且改动很小,否则不修改生产代码。
15
+ - fixture 应尽量确定性,并尽量局部化。
16
+
17
+ ## Verification Contract
18
+ - 运行相关测试命令或 Harness 配置的验证命令。
19
+ - 如果全量测试成本过高,记录定向命令和原因。
20
+
21
+ ## Report Contract
22
+ - 覆盖的场景。
23
+ - 修改文件。
24
+ - 验证结果。
25
+ - 剩余未覆盖风险。
26
+
27
+ ## Outputs
28
+ - 测试文件或 fixture 更新。
29
+ - 验证结果。
30
+ - 覆盖场景总结。
@@ -0,0 +1,29 @@
1
+ queries:
2
+ - related files
3
+ - symbols
4
+ - call graph
5
+ - dependencies
6
+ - impact analysis
7
+ mcp_preflight:
8
+ codegraph:
9
+ required: true
10
+ ask_for:
11
+ - related_files
12
+ - test_targets
13
+ - dependencies
14
+ - callers
15
+ - impacted_paths
16
+ knowledgeGraph:
17
+ required: false
18
+ ask_for:
19
+ - test_strategy
20
+ - known_edge_cases
21
+ - runbooks
22
+ - historical_bugs
23
+ stop_conditions:
24
+ - expected behavior is unclear
25
+ - no test runner can be identified
26
+ - test data or fixture requirements are unknown
27
+ fallbackInclude:
28
+ - README.md
29
+ - src
@@ -0,0 +1,2 @@
1
+ - name: git status
2
+ command: git status --short