hunter-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.
- package/dist/bin.js +127 -106
- package/package.json +2 -2
- package/resources/harness/general/.harness-build.json +1 -1
- package/resources/harness/general/harness-archive/SKILL.md +215 -215
- package/resources/harness/general/harness-codebase-map/SKILL.md +112 -112
- package/resources/harness/general/harness-codebase-map/templates/map-summary.md +3 -3
- package/resources/harness/general/harness-knowledge-ingest/SKILL.md +246 -246
- package/resources/harness/general/harness-knowledge-query/SKILL.md +164 -164
- package/resources/harness/general/harness-plan/SKILL.md +127 -127
- package/resources/harness/general/harness-review/SKILL.md +156 -156
- package/resources/harness/general/harness-run/SKILL.md +132 -132
- package/resources/harness/general/harness-submit/SKILL.md +159 -159
- package/resources/harness/general/harness-sync/SKILL.md +82 -82
- package/resources/harness/general/harness-test/SKILL.md +180 -180
- package/resources/harness/general/scripts/harness_deploy.py +580 -580
- package/resources/harness/java/.harness-build.json +1 -1
- package/resources/harness/java/harness-apidoc/SKILL.md +86 -86
- package/resources/harness/java/harness-archive/SKILL.md +215 -215
- package/resources/harness/java/harness-codebase-map/SKILL.md +112 -112
- package/resources/harness/java/harness-codebase-map/templates/map-summary.md +3 -3
- package/resources/harness/java/harness-knowledge-ingest/SKILL.md +246 -246
- package/resources/harness/java/harness-knowledge-query/SKILL.md +164 -164
- package/resources/harness/java/harness-package/SKILL.md +87 -87
- package/resources/harness/java/harness-plan/SKILL.md +127 -127
- package/resources/harness/java/harness-review/SKILL.md +156 -156
- package/resources/harness/java/harness-run/SKILL.md +148 -148
- package/resources/harness/java/harness-submit/SKILL.md +166 -166
- package/resources/harness/java/harness-sync/SKILL.md +82 -82
- package/resources/harness/java/harness-test/SKILL.md +192 -192
- package/resources/harness/java/scripts/harness_deploy.py +580 -580
- package/resources/harness/manifests/general.json +13 -33
- package/resources/harness/manifests/java.json +15 -35
- package/resources/bootstrap-ir/manifest.json +0 -19
- package/resources/bootstrap-ir/skills/harness-apidoc.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-archive.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-codebase-map.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-knowledge-ingest.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-package.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-plan.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-review.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-run.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-skill-optimizer.yaml +0 -28
- package/resources/bootstrap-ir/skills/harness-submit.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-sync.yaml +0 -24
- package/resources/bootstrap-ir/skills/harness-test.yaml +0 -24
- package/resources/bootstrap-ir/templates/claude-code-skill.md +0 -12
- package/resources/harness/general/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/archive/2026-01-10-ledger-reconciliation/reports/final/summary-data.json +0 -43
- package/resources/harness/general/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/archive/2026-02-14-ledger-snapshot-followup/reports/final/summary-data.json +0 -38
- package/resources/harness/general/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/archive/2026-03-05-webhook-contract/reports/final/summary-data.json +0 -36
- package/resources/harness/general/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/project.yaml +0 -1
- package/resources/harness/general/harness-knowledge-ingest/tests/test_harness_knowledge.py +0 -1792
- package/resources/harness/java/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/archive/2026-01-10-ledger-reconciliation/reports/final/summary-data.json +0 -43
- package/resources/harness/java/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/archive/2026-02-14-ledger-snapshot-followup/reports/final/summary-data.json +0 -38
- package/resources/harness/java/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/archive/2026-03-05-webhook-contract/reports/final/summary-data.json +0 -36
- package/resources/harness/java/harness-knowledge-ingest/tests/fixtures/mcp-eval-project/.harness/project.yaml +0 -1
- package/resources/harness/java/harness-knowledge-ingest/tests/test_harness_knowledge.py +0 -1792
- package/resources/manifest.json +0 -19
- package/resources/skills/harness-apidoc/SKILL.md +0 -50
- package/resources/skills/harness-archive/SKILL.md +0 -48
- package/resources/skills/harness-codebase-map/SKILL.md +0 -53
- package/resources/skills/harness-knowledge-ingest/SKILL.md +0 -48
- package/resources/skills/harness-package/SKILL.md +0 -48
- package/resources/skills/harness-plan/SKILL.md +0 -51
- package/resources/skills/harness-review/SKILL.md +0 -50
- package/resources/skills/harness-run/SKILL.md +0 -48
- package/resources/skills/harness-skill-optimizer/SKILL.md +0 -54
- package/resources/skills/harness-submit/SKILL.md +0 -47
- package/resources/skills/harness-sync/SKILL.md +0 -48
- package/resources/skills/harness-test/SKILL.md +0 -50
|
@@ -1,215 +1,215 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: harness-archive
|
|
3
|
-
description: "归档所有变更产出(计划/测试报告/审查/SQL/API文档)到 .harness/archive/,含归档元数据和可视化最终总结。使用场景:归档、完成归档、收尾、打包产出物"
|
|
4
|
-
argument-hint: "变更名或留空自动检测"
|
|
5
|
-
effort: medium
|
|
6
|
-
allowed-tools: [Bash(powershell.exe:*), Read, Write, Edit, Glob, Grep]
|
|
7
|
-
disallowed-tools:
|
|
8
|
-
- Bash(git *)
|
|
9
|
-
- Bash(mvn *)
|
|
10
|
-
- Bash(ls *)
|
|
11
|
-
- Bash(find *)
|
|
12
|
-
- Bash(grep *)
|
|
13
|
-
- Bash(cat *)
|
|
14
|
-
- Bash(cp *)
|
|
15
|
-
- Bash(mv *)
|
|
16
|
-
- Bash(rm *)
|
|
17
|
-
- Bash(mkdir *)
|
|
18
|
-
- Bash(touch *)
|
|
19
|
-
- Bash(sed *)
|
|
20
|
-
- Bash(awk *)
|
|
21
|
-
- Bash(curl *)
|
|
22
|
-
---
|
|
23
|
-
<!-- generated by harness_deploy.py; core=
|
|
24
|
-
# harness-archive — 变更归档
|
|
25
|
-
|
|
26
|
-
## Purpose
|
|
27
|
-
|
|
28
|
-
将 `.harness/changes/<change-name>/` 的所有产出移入 `.harness/archive/YYYY-MM-DD-<change-name>/`,生成归档元数据和可视化最终报告,释放工作区。
|
|
29
|
-
|
|
30
|
-
## When to Use
|
|
31
|
-
|
|
32
|
-
使用场景:
|
|
33
|
-
|
|
34
|
-
- 用户说"归档 / 完成归档 / 收尾 / 打包产出物"。
|
|
35
|
-
- submit 已推送、test/review 报告已就绪(或已明确标记跳过/未运行),需要封存变更产出。
|
|
36
|
-
- 变更闭环最后一站,归档后从工作区移除 `.harness/changes/<change-name>/`。
|
|
37
|
-
|
|
38
|
-
跳过场景:
|
|
39
|
-
|
|
40
|
-
- 变更尚未 submit 推送(归档前 commit 必须已 push)。
|
|
41
|
-
- 仍存在未结清的 test/review 验证(除非已明确标记 CONDITIONAL_OK)。
|
|
42
|
-
|
|
43
|
-
自动调用边界:
|
|
44
|
-
|
|
45
|
-
- 归档涉及移动/删除原变更目录,支持被其他 skill 调用,但调用前必须确保前置条件已满足;也支持用户显式 `/harness-archive` 调用。
|
|
46
|
-
- 归档前确认是强制阻断检查点,用户拒绝 → 终止流程,不执行任何操作。
|
|
47
|
-
|
|
48
|
-
## 前置条件
|
|
49
|
-
|
|
50
|
-
- commit 已 push(`git log @{u}..HEAD` 输出为空)
|
|
51
|
-
- **最终 hash 来源**:worktree 模式(`meta/worktree.json` requested=true)下读 ledger 的 `mergeFinalHash`(由 `/harness-submit` 合并段写入);主目录模式读 submit 的 `final pushed hash`。当前 `git rev-parse HEAD` 须一致
|
|
52
|
-
- test 报告存在或标记"跳过";review 报告存在或标记"未运行 review"(review 不阻塞归档)
|
|
53
|
-
|
|
54
|
-
## Inputs
|
|
55
|
-
|
|
56
|
-
- `$ARGUMENTS`:变更名(可选,留空时 Glob `.harness/changes/*/plans/*-plan.md` 自动检测,排除 `.harness/archive/`)
|
|
57
|
-
- 相关文件:`.harness/changes/<change-name>/logs/execution-log.md`、`.harness/changes/<change-name>/events.ndjson`、`evidence/verification-ledger.json`、各阶段 reports/
|
|
58
|
-
|
|
59
|
-
## 统一读取协议
|
|
60
|
-
|
|
61
|
-
1. **`.harness/changes/<change-name>/` 是唯一真相源** — 所有输入从该目录读取,产物写入对应子目录
|
|
62
|
-
2. **change-name 优先从 frontmatter 读取** — `spec/*-design.md`、`plans/*-plan.md` 的 YAML `change-name`
|
|
63
|
-
3. **frontmatter 缺失时兼容旧格式** — 从路径推断,标记 `🟡 legacy-plan`,不失败
|
|
64
|
-
4. **spec** — 设计真相源:`spec/<change>-design.md`
|
|
65
|
-
5. **plan** — 任务真相源:`plans/<change>-plan.md`
|
|
66
|
-
6. **implementation-detail** — 自适应执行参考;legacy 缺失 🟡WARN,不阻断
|
|
67
|
-
7. **test-scenarios** — 测试真相源:`plans/<change>-test-scenarios.md`
|
|
68
|
-
8. **禁止读取 `docs/superpowers/` 作为正式输入** — 旧草稿仅人工线索
|
|
69
|
-
|
|
70
|
-
状态目录分层:新路径优先,旧路径兼容 → [[../protocols/state-layout-protocol.md|state-layout-protocol]]
|
|
71
|
-
|
|
72
|
-
## Workflow
|
|
73
|
-
|
|
74
|
-
### Phase 0:读取规则和上下文
|
|
75
|
-
|
|
76
|
-
1. 读取本文件。
|
|
77
|
-
2. 按需读取 `reference.md`(归档流程、manifest、summary-data、final-summary 渲染、目录结构与最终状态规则)。
|
|
78
|
-
3. 读取共用约束:
|
|
79
|
-
- `../protocols/archive-report-protocol.md`
|
|
80
|
-
- `../protocols/state-layout-protocol.md`
|
|
81
|
-
- `../protocols/powershell-protocol.md`
|
|
82
|
-
- `../protocols/sensitive-info-protocol.md`
|
|
83
|
-
- `../protocols/evidence-based-reporting-protocol.md`
|
|
84
|
-
- `../protocols/report-pipeline-protocol.md`
|
|
85
|
-
4. 解析 `$ARGUMENTS`:留空时 Glob 自动检测未归档变更,排除 `.harness/archive/`。
|
|
86
|
-
|
|
87
|
-
### Phase 1:确认归档对象(扫描未归档变更)
|
|
88
|
-
|
|
89
|
-
用 Glob 搜索 `.harness/changes/*/plans/*-plan.md`(排除 `.harness/archive/`),展示变更概要。
|
|
90
|
-
|
|
91
|
-
- **Read `checklist.md`** — 归档前检查项
|
|
92
|
-
- 发现多个未归档变更 → 让用户选择或终止
|
|
93
|
-
|
|
94
|
-
### Phase 2:确认归档 ⚠️ 强制阻断
|
|
95
|
-
|
|
96
|
-
AskUserQuestion 让用户确认归档操作。**用户拒绝 → 终止流程,不执行任何操作。**
|
|
97
|
-
|
|
98
|
-
- **Read `reference.md`** — 确认对话框的内容格式
|
|
99
|
-
|
|
100
|
-
### Phase 3:执行归档
|
|
101
|
-
|
|
102
|
-
1. append `phase.start` 事件。
|
|
103
|
-
2. 运行 `python <skills-root>/scripts/harness_archive.py status --change-dir ".harness/changes/<change-name>" --json` 前置检查。
|
|
104
|
-
3. 运行 `python <skills-root>/scripts/harness_archive.py finalize --change-dir ".harness/changes/<change-name>" --archive-root ".harness/archive" --json`;读 JSON(移动、collect、render、validate、manifest 比对)。**finalize 不再同步执行知识维护**(§8.2):它写一个 `pending` maintenance-outbox 项即返回,`knowledgeMaintenance=QUEUED`;写 outbox 失败时 `NOT_QUEUED`(warning,不回滚 archive,总状态 CONDITIONAL)。后续由 `harness-sync` / `harness_knowledge.py maintain` 异步推进 outbox。
|
|
105
|
-
4. 模型补写 `meta/archive-meta.md` 的维护者结论 / knownRisks / manualActions(脚本占位字段)。
|
|
106
|
-
5. append `phase.end` 事件。**finalize 失败或 validate 报错时不删除原目录**。
|
|
107
|
-
|
|
108
|
-
- **Read `reference.md`** — finalize 输出字段、archive-meta 格式、CONDITIONAL_OK 规则
|
|
109
|
-
- **Read `templates/summary-data-template.json`** — summary-data 数据结构
|
|
110
|
-
- **Read `templates/render-summary.mjs`** — final-summary 渲染脚本(finalize 内嵌调用)
|
|
111
|
-
|
|
112
|
-
### Phase 4:验证与提示
|
|
113
|
-
|
|
114
|
-
验证归档目录完整 → 提示用户归档完成。
|
|
115
|
-
|
|
116
|
-
- **Read `checklist.md`** — 归档后验证项
|
|
117
|
-
|
|
118
|
-
## P0 执行可信度规则
|
|
119
|
-
|
|
120
|
-
- 命令结果不得靠猜测;普通 Bash 被拒 → 立即改用等价 PowerShell 重试一次
|
|
121
|
-
- 仅 PowerShell 成功且有明确证据(构建/git/测试输出、文件存在、exit 0)时可标 ✅OK;否则 ❌FAIL 或 🟡WARN
|
|
122
|
-
- 禁止把 hook 拒绝、静态验证、无输出、用户跳过说成成功 → 详见 [[../protocols/powershell-protocol.md|powershell-protocol]]、[[../protocols/evidence-based-reporting-protocol.md|evidence-based-reporting-protocol]]
|
|
123
|
-
|
|
124
|
-
## 关键规则(硬门禁速查)
|
|
125
|
-
|
|
126
|
-
> 每条规则的详细判定、模板见 `reference.md` 对应章节;归档报告协议见 `../protocols/archive-report-protocol.md`,Shell 执行安全见 `../protocols/powershell-protocol.md`,敏感信息见 `../protocols/sensitive-info-protocol.md`,证据化报告见 `../protocols/evidence-based-reporting-protocol.md`,状态目录见 `../protocols/state-layout-protocol.md`。
|
|
127
|
-
|
|
128
|
-
### 一、同一时间最多 1 个未归档变更
|
|
129
|
-
|
|
130
|
-
扫描排除 `.harness/archive/`;多个未归档变更 → 让用户选择或终止,不批量归档。
|
|
131
|
-
|
|
132
|
-
### 二、归档前确认是强制阻断检查点
|
|
133
|
-
|
|
134
|
-
AskUserQuestion 确认;用户拒绝 → 终止,不执行任何操作。
|
|
135
|
-
|
|
136
|
-
### 三、文件移动只用内置工具或 PowerShell
|
|
137
|
-
|
|
138
|
-
移动用 Read+Write+验证 或 PowerShell;**禁止 Bash mv/cp/rm**。移动失败时不删除原目录,报错退出让用户手动处理。
|
|
139
|
-
|
|
140
|
-
### 四、数据化归档门禁(先数据后渲染)
|
|
141
|
-
|
|
142
|
-
必须通过 `harness_archive.py finalize` 生成 `reports/final/summary-data.json` 与 `final-summary.html` 并完成 validate;**禁止模型临场写 500+ 行 HTML**。统计数字只能来自 summary-data、events、ledger 或 manifest。详见 `../protocols/report-pipeline-protocol.md`、`../protocols/archive-report-protocol.md`、`reference.md`。
|
|
143
|
-
|
|
144
|
-
### 五、manifest/checksum 必须存在
|
|
145
|
-
|
|
146
|
-
归档前后生成 `evidence/archive-manifest-before.json` / `archive-manifest-after.json`(path/size/sha256),before/after 不一致时**不得删除原目录**。复杂 PowerShell 写入 `scripts/*.ps1` 后 `-File` 执行,禁止内联 `$` / `$_` / `@{}`。详见 `reference.md`。
|
|
147
|
-
|
|
148
|
-
### 六、归档前确认四项(缺一不可)
|
|
149
|
-
|
|
150
|
-
- commit 已 push(`git log @{u}..HEAD` 输出为空)
|
|
151
|
-
- **final hash 来源**:worktree 模式(requested=true)下读 ledger `mergeFinalHash`(submit 合并段);否则读 submit 日志 `final pushed hash`。当前 HEAD 须一致
|
|
152
|
-
- test 报告存在,或标记"跳过"/"未运行测试"
|
|
153
|
-
- review 报告:存在则作 📝ADVISORY 归档材料;不存在标记"📝ADVISORY:未运行 review"(review 不阻塞归档)
|
|
154
|
-
|
|
155
|
-
### 七、verification-ledger 汇总状态
|
|
156
|
-
|
|
157
|
-
归档前读 `evidence/verification-ledger.json`,提取各阶段 status、postTestClassification、复用关系,供 final-summary 真实展示状态演进。若 ledger 有 `postTestClassification`,final-summary 必须展示该分类及对应的复用/重测决策。
|
|
158
|
-
|
|
159
|
-
### 八、final-summary 不得伪造且必须展示状态演进
|
|
160
|
-
|
|
161
|
-
无测试报告 → 显示"未运行测试 / 静态验证",不得 100% 通过率;无 review → "📝ADVISORY:未运行 review"。状态用 ✅OK / 🟡WARN / 🔁REUSED / 🔁RETESTED / 📝ADVISORY / 🧹NON_BEHAVIORAL_CLEANUP,复用前一阶段结果显示 🔁REUSED,**不得伪装成重新执行,不得无脑全绿**。
|
|
162
|
-
|
|
163
|
-
**final-summary 必须产出**:Node 渲染器不可用/超时/exit 非 0/未产出文件时,`harness_archive.py` 自动用内置 Python fallback 渲染(含 changeName/finalStatus/commands/verification/changedFiles/archiveManifest/knownRisks/manualActions/maintenanceNotes,USER_SKIPPED/BLOCKED_BY_DBA/失败状态可见,全部 HTML 转义)。Node 与 Python fallback **都失败**时,finalize 立即恢复原 change 目录并 exit 非 0,**绝不归档一个没有 final-summary.html 的变更**。
|
|
164
|
-
|
|
165
|
-
### 九、CONDITIONAL_OK 最终状态
|
|
166
|
-
|
|
167
|
-
API 测试 `USER_SKIPPED` 或 DB 兼容 `BLOCKED_BY_DBA` 时,最终状态必须是 `CONDITIONAL_OK`,不能显示纯 `OK`。
|
|
168
|
-
|
|
169
|
-
### 十、未提交测试文件归档
|
|
170
|
-
|
|
171
|
-
未提交但用于验证的测试文件必须归档到 `backups/uncommitted-tests/` 并在 final-summary 中展示。
|
|
172
|
-
|
|
173
|
-
### 十一、phase.start 事件前置
|
|
174
|
-
|
|
175
|
-
阶段 0 之前必须先 append `phase.start` 事件(`harness_events.py append`);不得等归档完成才补。归档后 events.ndjson 与自动渲染的 execution-log.md 一起移入 archive。
|
|
176
|
-
|
|
177
|
-
### 十二、Shell 安全 / 敏感信息 / 证据化报告
|
|
178
|
-
|
|
179
|
-
git 命令通过 `powershell.exe -Command "..."` 执行;archive-meta.md 和 final-summary.html 不得含明文 token/密码/密钥;归档报告必须区分 ✅真实成功 / 🟡跳过·静态验证 / ❌失败。
|
|
180
|
-
|
|
181
|
-
## Output Format
|
|
182
|
-
|
|
183
|
-
> 归档元数据格式见 `reference.md` 的 archive-meta 模板;最终报告由 `templates/summary-data-template.json` 数据结构 + `templates/render-summary.mjs` 固定脚本渲染。
|
|
184
|
-
|
|
185
|
-
产出文件:
|
|
186
|
-
|
|
187
|
-
- `.harness/archive/YYYY-MM-DD-<change-name>/meta/archive-meta.md` — 归档元数据
|
|
188
|
-
- `.harness/archive/YYYY-MM-DD-<change-name>/events.ndjson` — 结构化事件层(新流程推荐;旧 archive 可缺失)
|
|
189
|
-
- `.harness/archive/YYYY-MM-DD-<change-name>/reports/final/summary-data.json` — 最终报告数据源
|
|
190
|
-
- `.harness/archive/YYYY-MM-DD-<change-name>/reports/final/final-summary.html` — 由 `render-summary.mjs` 渲染(Node 不可用或失败时由 `harness_archive.py` 内置 Python fallback 渲染);**始终必须存在**,否则 finalize 恢复原 change 目录并 exit 非 0
|
|
191
|
-
- `.harness/archive/YYYY-MM-DD-<change-name>/evidence/archive-manifest-before.json` / `archive-manifest-after.json` — 归档前后 manifest/checksum
|
|
192
|
-
|
|
193
|
-
## 渐进披露
|
|
194
|
-
|
|
195
|
-
- **Read `checklist.md`** 仅在 Phase 1 归档前检查和 Phase 4 验证时 — 含归档前检查项和归档后验证项
|
|
196
|
-
- **Read `reference.md`** 仅在 Phase 0/2/3 时 — 含归档流程、archive-meta 格式、summary-data 字段说明、final-summary 渲染规则、目录结构与最终状态规则
|
|
197
|
-
- **Read `reference.md`** 仅在 Phase 3 finalize 时 — summary-data、final-summary 校验与 archive-meta 补写
|
|
198
|
-
- **Read `templates/summary-data-template.json`** 仅在 Phase 3 生成 `summary-data.json` 时 — 含最终报告数据结构
|
|
199
|
-
- **Read `templates/render-summary.mjs`** 仅在 Phase 3 渲染 `final-summary.html` 时 — 固定 HTML 渲染脚本
|
|
200
|
-
|
|
201
|
-
## 交互白名单
|
|
202
|
-
|
|
203
|
-
**仅允许**归档确认(Phase 2 AskUserQuestion);拒绝 → 终止,不执行任何移动。
|
|
204
|
-
|
|
205
|
-
## 执行日志
|
|
206
|
-
|
|
207
|
-
`events.ndjson` 为唯一事实源(schema_version 2,`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止手工 Edit**。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
|
|
208
|
-
|
|
209
|
-
```powershell
|
|
210
|
-
python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
|
|
211
|
-
```
|
|
212
|
-
|
|
213
|
-
> **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
|
|
214
|
-
|
|
215
|
-
> **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
|
|
1
|
+
---
|
|
2
|
+
name: harness-archive
|
|
3
|
+
description: "归档所有变更产出(计划/测试报告/审查/SQL/API文档)到 .harness/archive/,含归档元数据和可视化最终总结。使用场景:归档、完成归档、收尾、打包产出物"
|
|
4
|
+
argument-hint: "变更名或留空自动检测"
|
|
5
|
+
effort: medium
|
|
6
|
+
allowed-tools: [Bash(powershell.exe:*), Read, Write, Edit, Glob, Grep]
|
|
7
|
+
disallowed-tools:
|
|
8
|
+
- Bash(git *)
|
|
9
|
+
- Bash(mvn *)
|
|
10
|
+
- Bash(ls *)
|
|
11
|
+
- Bash(find *)
|
|
12
|
+
- Bash(grep *)
|
|
13
|
+
- Bash(cat *)
|
|
14
|
+
- Bash(cp *)
|
|
15
|
+
- Bash(mv *)
|
|
16
|
+
- Bash(rm *)
|
|
17
|
+
- Bash(mkdir *)
|
|
18
|
+
- Bash(touch *)
|
|
19
|
+
- Bash(sed *)
|
|
20
|
+
- Bash(awk *)
|
|
21
|
+
- Bash(curl *)
|
|
22
|
+
---
|
|
23
|
+
<!-- generated by harness_deploy.py; core=76dd32302df53f0b; overlay=none; do not edit -->
|
|
24
|
+
# harness-archive — 变更归档
|
|
25
|
+
|
|
26
|
+
## Purpose
|
|
27
|
+
|
|
28
|
+
将 `.harness/changes/<change-name>/` 的所有产出移入 `.harness/archive/YYYY-MM-DD-<change-name>/`,生成归档元数据和可视化最终报告,释放工作区。
|
|
29
|
+
|
|
30
|
+
## When to Use
|
|
31
|
+
|
|
32
|
+
使用场景:
|
|
33
|
+
|
|
34
|
+
- 用户说"归档 / 完成归档 / 收尾 / 打包产出物"。
|
|
35
|
+
- submit 已推送、test/review 报告已就绪(或已明确标记跳过/未运行),需要封存变更产出。
|
|
36
|
+
- 变更闭环最后一站,归档后从工作区移除 `.harness/changes/<change-name>/`。
|
|
37
|
+
|
|
38
|
+
跳过场景:
|
|
39
|
+
|
|
40
|
+
- 变更尚未 submit 推送(归档前 commit 必须已 push)。
|
|
41
|
+
- 仍存在未结清的 test/review 验证(除非已明确标记 CONDITIONAL_OK)。
|
|
42
|
+
|
|
43
|
+
自动调用边界:
|
|
44
|
+
|
|
45
|
+
- 归档涉及移动/删除原变更目录,支持被其他 skill 调用,但调用前必须确保前置条件已满足;也支持用户显式 `/harness-archive` 调用。
|
|
46
|
+
- 归档前确认是强制阻断检查点,用户拒绝 → 终止流程,不执行任何操作。
|
|
47
|
+
|
|
48
|
+
## 前置条件
|
|
49
|
+
|
|
50
|
+
- commit 已 push(`git log @{u}..HEAD` 输出为空)
|
|
51
|
+
- **最终 hash 来源**:worktree 模式(`meta/worktree.json` requested=true)下读 ledger 的 `mergeFinalHash`(由 `/harness-submit` 合并段写入);主目录模式读 submit 的 `final pushed hash`。当前 `git rev-parse HEAD` 须一致
|
|
52
|
+
- test 报告存在或标记"跳过";review 报告存在或标记"未运行 review"(review 不阻塞归档)
|
|
53
|
+
|
|
54
|
+
## Inputs
|
|
55
|
+
|
|
56
|
+
- `$ARGUMENTS`:变更名(可选,留空时 Glob `.harness/changes/*/plans/*-plan.md` 自动检测,排除 `.harness/archive/`)
|
|
57
|
+
- 相关文件:`.harness/changes/<change-name>/logs/execution-log.md`、`.harness/changes/<change-name>/events.ndjson`、`evidence/verification-ledger.json`、各阶段 reports/
|
|
58
|
+
|
|
59
|
+
## 统一读取协议
|
|
60
|
+
|
|
61
|
+
1. **`.harness/changes/<change-name>/` 是唯一真相源** — 所有输入从该目录读取,产物写入对应子目录
|
|
62
|
+
2. **change-name 优先从 frontmatter 读取** — `spec/*-design.md`、`plans/*-plan.md` 的 YAML `change-name`
|
|
63
|
+
3. **frontmatter 缺失时兼容旧格式** — 从路径推断,标记 `🟡 legacy-plan`,不失败
|
|
64
|
+
4. **spec** — 设计真相源:`spec/<change>-design.md`
|
|
65
|
+
5. **plan** — 任务真相源:`plans/<change>-plan.md`
|
|
66
|
+
6. **implementation-detail** — 自适应执行参考;legacy 缺失 🟡WARN,不阻断
|
|
67
|
+
7. **test-scenarios** — 测试真相源:`plans/<change>-test-scenarios.md`
|
|
68
|
+
8. **禁止读取 `docs/superpowers/` 作为正式输入** — 旧草稿仅人工线索
|
|
69
|
+
|
|
70
|
+
状态目录分层:新路径优先,旧路径兼容 → [[../protocols/state-layout-protocol.md|state-layout-protocol]]
|
|
71
|
+
|
|
72
|
+
## Workflow
|
|
73
|
+
|
|
74
|
+
### Phase 0:读取规则和上下文
|
|
75
|
+
|
|
76
|
+
1. 读取本文件。
|
|
77
|
+
2. 按需读取 `reference.md`(归档流程、manifest、summary-data、final-summary 渲染、目录结构与最终状态规则)。
|
|
78
|
+
3. 读取共用约束:
|
|
79
|
+
- `../protocols/archive-report-protocol.md`
|
|
80
|
+
- `../protocols/state-layout-protocol.md`
|
|
81
|
+
- `../protocols/powershell-protocol.md`
|
|
82
|
+
- `../protocols/sensitive-info-protocol.md`
|
|
83
|
+
- `../protocols/evidence-based-reporting-protocol.md`
|
|
84
|
+
- `../protocols/report-pipeline-protocol.md`
|
|
85
|
+
4. 解析 `$ARGUMENTS`:留空时 Glob 自动检测未归档变更,排除 `.harness/archive/`。
|
|
86
|
+
|
|
87
|
+
### Phase 1:确认归档对象(扫描未归档变更)
|
|
88
|
+
|
|
89
|
+
用 Glob 搜索 `.harness/changes/*/plans/*-plan.md`(排除 `.harness/archive/`),展示变更概要。
|
|
90
|
+
|
|
91
|
+
- **Read `checklist.md`** — 归档前检查项
|
|
92
|
+
- 发现多个未归档变更 → 让用户选择或终止
|
|
93
|
+
|
|
94
|
+
### Phase 2:确认归档 ⚠️ 强制阻断
|
|
95
|
+
|
|
96
|
+
AskUserQuestion 让用户确认归档操作。**用户拒绝 → 终止流程,不执行任何操作。**
|
|
97
|
+
|
|
98
|
+
- **Read `reference.md`** — 确认对话框的内容格式
|
|
99
|
+
|
|
100
|
+
### Phase 3:执行归档
|
|
101
|
+
|
|
102
|
+
1. append `phase.start` 事件。
|
|
103
|
+
2. 运行 `python <skills-root>/scripts/harness_archive.py status --change-dir ".harness/changes/<change-name>" --json` 前置检查。
|
|
104
|
+
3. 运行 `python <skills-root>/scripts/harness_archive.py finalize --change-dir ".harness/changes/<change-name>" --archive-root ".harness/archive" --json`;读 JSON(移动、collect、render、validate、manifest 比对)。**finalize 不再同步执行知识维护**(§8.2):它写一个 `pending` maintenance-outbox 项即返回,`knowledgeMaintenance=QUEUED`;写 outbox 失败时 `NOT_QUEUED`(warning,不回滚 archive,总状态 CONDITIONAL)。后续由 `harness-sync` / `harness_knowledge.py maintain` 异步推进 outbox。
|
|
105
|
+
4. 模型补写 `meta/archive-meta.md` 的维护者结论 / knownRisks / manualActions(脚本占位字段)。
|
|
106
|
+
5. append `phase.end` 事件。**finalize 失败或 validate 报错时不删除原目录**。
|
|
107
|
+
|
|
108
|
+
- **Read `reference.md`** — finalize 输出字段、archive-meta 格式、CONDITIONAL_OK 规则
|
|
109
|
+
- **Read `templates/summary-data-template.json`** — summary-data 数据结构
|
|
110
|
+
- **Read `templates/render-summary.mjs`** — final-summary 渲染脚本(finalize 内嵌调用)
|
|
111
|
+
|
|
112
|
+
### Phase 4:验证与提示
|
|
113
|
+
|
|
114
|
+
验证归档目录完整 → 提示用户归档完成。
|
|
115
|
+
|
|
116
|
+
- **Read `checklist.md`** — 归档后验证项
|
|
117
|
+
|
|
118
|
+
## P0 执行可信度规则
|
|
119
|
+
|
|
120
|
+
- 命令结果不得靠猜测;普通 Bash 被拒 → 立即改用等价 PowerShell 重试一次
|
|
121
|
+
- 仅 PowerShell 成功且有明确证据(构建/git/测试输出、文件存在、exit 0)时可标 ✅OK;否则 ❌FAIL 或 🟡WARN
|
|
122
|
+
- 禁止把 hook 拒绝、静态验证、无输出、用户跳过说成成功 → 详见 [[../protocols/powershell-protocol.md|powershell-protocol]]、[[../protocols/evidence-based-reporting-protocol.md|evidence-based-reporting-protocol]]
|
|
123
|
+
|
|
124
|
+
## 关键规则(硬门禁速查)
|
|
125
|
+
|
|
126
|
+
> 每条规则的详细判定、模板见 `reference.md` 对应章节;归档报告协议见 `../protocols/archive-report-protocol.md`,Shell 执行安全见 `../protocols/powershell-protocol.md`,敏感信息见 `../protocols/sensitive-info-protocol.md`,证据化报告见 `../protocols/evidence-based-reporting-protocol.md`,状态目录见 `../protocols/state-layout-protocol.md`。
|
|
127
|
+
|
|
128
|
+
### 一、同一时间最多 1 个未归档变更
|
|
129
|
+
|
|
130
|
+
扫描排除 `.harness/archive/`;多个未归档变更 → 让用户选择或终止,不批量归档。
|
|
131
|
+
|
|
132
|
+
### 二、归档前确认是强制阻断检查点
|
|
133
|
+
|
|
134
|
+
AskUserQuestion 确认;用户拒绝 → 终止,不执行任何操作。
|
|
135
|
+
|
|
136
|
+
### 三、文件移动只用内置工具或 PowerShell
|
|
137
|
+
|
|
138
|
+
移动用 Read+Write+验证 或 PowerShell;**禁止 Bash mv/cp/rm**。移动失败时不删除原目录,报错退出让用户手动处理。
|
|
139
|
+
|
|
140
|
+
### 四、数据化归档门禁(先数据后渲染)
|
|
141
|
+
|
|
142
|
+
必须通过 `harness_archive.py finalize` 生成 `reports/final/summary-data.json` 与 `final-summary.html` 并完成 validate;**禁止模型临场写 500+ 行 HTML**。统计数字只能来自 summary-data、events、ledger 或 manifest。详见 `../protocols/report-pipeline-protocol.md`、`../protocols/archive-report-protocol.md`、`reference.md`。
|
|
143
|
+
|
|
144
|
+
### 五、manifest/checksum 必须存在
|
|
145
|
+
|
|
146
|
+
归档前后生成 `evidence/archive-manifest-before.json` / `archive-manifest-after.json`(path/size/sha256),before/after 不一致时**不得删除原目录**。复杂 PowerShell 写入 `scripts/*.ps1` 后 `-File` 执行,禁止内联 `$` / `$_` / `@{}`。详见 `reference.md`。
|
|
147
|
+
|
|
148
|
+
### 六、归档前确认四项(缺一不可)
|
|
149
|
+
|
|
150
|
+
- commit 已 push(`git log @{u}..HEAD` 输出为空)
|
|
151
|
+
- **final hash 来源**:worktree 模式(requested=true)下读 ledger `mergeFinalHash`(submit 合并段);否则读 submit 日志 `final pushed hash`。当前 HEAD 须一致
|
|
152
|
+
- test 报告存在,或标记"跳过"/"未运行测试"
|
|
153
|
+
- review 报告:存在则作 📝ADVISORY 归档材料;不存在标记"📝ADVISORY:未运行 review"(review 不阻塞归档)
|
|
154
|
+
|
|
155
|
+
### 七、verification-ledger 汇总状态
|
|
156
|
+
|
|
157
|
+
归档前读 `evidence/verification-ledger.json`,提取各阶段 status、postTestClassification、复用关系,供 final-summary 真实展示状态演进。若 ledger 有 `postTestClassification`,final-summary 必须展示该分类及对应的复用/重测决策。
|
|
158
|
+
|
|
159
|
+
### 八、final-summary 不得伪造且必须展示状态演进
|
|
160
|
+
|
|
161
|
+
无测试报告 → 显示"未运行测试 / 静态验证",不得 100% 通过率;无 review → "📝ADVISORY:未运行 review"。状态用 ✅OK / 🟡WARN / 🔁REUSED / 🔁RETESTED / 📝ADVISORY / 🧹NON_BEHAVIORAL_CLEANUP,复用前一阶段结果显示 🔁REUSED,**不得伪装成重新执行,不得无脑全绿**。
|
|
162
|
+
|
|
163
|
+
**final-summary 必须产出**:Node 渲染器不可用/超时/exit 非 0/未产出文件时,`harness_archive.py` 自动用内置 Python fallback 渲染(含 changeName/finalStatus/commands/verification/changedFiles/archiveManifest/knownRisks/manualActions/maintenanceNotes,USER_SKIPPED/BLOCKED_BY_DBA/失败状态可见,全部 HTML 转义)。Node 与 Python fallback **都失败**时,finalize 立即恢复原 change 目录并 exit 非 0,**绝不归档一个没有 final-summary.html 的变更**。
|
|
164
|
+
|
|
165
|
+
### 九、CONDITIONAL_OK 最终状态
|
|
166
|
+
|
|
167
|
+
API 测试 `USER_SKIPPED` 或 DB 兼容 `BLOCKED_BY_DBA` 时,最终状态必须是 `CONDITIONAL_OK`,不能显示纯 `OK`。
|
|
168
|
+
|
|
169
|
+
### 十、未提交测试文件归档
|
|
170
|
+
|
|
171
|
+
未提交但用于验证的测试文件必须归档到 `backups/uncommitted-tests/` 并在 final-summary 中展示。
|
|
172
|
+
|
|
173
|
+
### 十一、phase.start 事件前置
|
|
174
|
+
|
|
175
|
+
阶段 0 之前必须先 append `phase.start` 事件(`harness_events.py append`);不得等归档完成才补。归档后 events.ndjson 与自动渲染的 execution-log.md 一起移入 archive。
|
|
176
|
+
|
|
177
|
+
### 十二、Shell 安全 / 敏感信息 / 证据化报告
|
|
178
|
+
|
|
179
|
+
git 命令通过 `powershell.exe -Command "..."` 执行;archive-meta.md 和 final-summary.html 不得含明文 token/密码/密钥;归档报告必须区分 ✅真实成功 / 🟡跳过·静态验证 / ❌失败。
|
|
180
|
+
|
|
181
|
+
## Output Format
|
|
182
|
+
|
|
183
|
+
> 归档元数据格式见 `reference.md` 的 archive-meta 模板;最终报告由 `templates/summary-data-template.json` 数据结构 + `templates/render-summary.mjs` 固定脚本渲染。
|
|
184
|
+
|
|
185
|
+
产出文件:
|
|
186
|
+
|
|
187
|
+
- `.harness/archive/YYYY-MM-DD-<change-name>/meta/archive-meta.md` — 归档元数据
|
|
188
|
+
- `.harness/archive/YYYY-MM-DD-<change-name>/events.ndjson` — 结构化事件层(新流程推荐;旧 archive 可缺失)
|
|
189
|
+
- `.harness/archive/YYYY-MM-DD-<change-name>/reports/final/summary-data.json` — 最终报告数据源
|
|
190
|
+
- `.harness/archive/YYYY-MM-DD-<change-name>/reports/final/final-summary.html` — 由 `render-summary.mjs` 渲染(Node 不可用或失败时由 `harness_archive.py` 内置 Python fallback 渲染);**始终必须存在**,否则 finalize 恢复原 change 目录并 exit 非 0
|
|
191
|
+
- `.harness/archive/YYYY-MM-DD-<change-name>/evidence/archive-manifest-before.json` / `archive-manifest-after.json` — 归档前后 manifest/checksum
|
|
192
|
+
|
|
193
|
+
## 渐进披露
|
|
194
|
+
|
|
195
|
+
- **Read `checklist.md`** 仅在 Phase 1 归档前检查和 Phase 4 验证时 — 含归档前检查项和归档后验证项
|
|
196
|
+
- **Read `reference.md`** 仅在 Phase 0/2/3 时 — 含归档流程、archive-meta 格式、summary-data 字段说明、final-summary 渲染规则、目录结构与最终状态规则
|
|
197
|
+
- **Read `reference.md`** 仅在 Phase 3 finalize 时 — summary-data、final-summary 校验与 archive-meta 补写
|
|
198
|
+
- **Read `templates/summary-data-template.json`** 仅在 Phase 3 生成 `summary-data.json` 时 — 含最终报告数据结构
|
|
199
|
+
- **Read `templates/render-summary.mjs`** 仅在 Phase 3 渲染 `final-summary.html` 时 — 固定 HTML 渲染脚本
|
|
200
|
+
|
|
201
|
+
## 交互白名单
|
|
202
|
+
|
|
203
|
+
**仅允许**归档确认(Phase 2 AskUserQuestion);拒绝 → 终止,不执行任何移动。
|
|
204
|
+
|
|
205
|
+
## 执行日志
|
|
206
|
+
|
|
207
|
+
`events.ndjson` 为唯一事实源(schema_version 2,`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止手工 Edit**。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
|
|
208
|
+
|
|
209
|
+
```powershell
|
|
210
|
+
python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
> **脚本接线**:`harness_events.py append`;`harness_archive.py finalize`;`harness_preflight.py check`;`harness_ledger.py can-reuse`;`harness_service.py ensure/stop`(须 `--files`/`serviceStart.inputFiles`)。JSON 输出按 D13 护栏解读。
|
|
214
|
+
|
|
215
|
+
> **Task 4 §6.1 写入契约**:普通 `append` = 加锁 -> 追加一行 -> fsync -> 解锁,**不 load 历史、不渲染**(O(1),跨进程锁 `events.ndjson.lock`,UUID 用完整 `uuid4().hex` 无需去重扫描)。仅 `--type phase.end` append 在追加成功后渲染一次 `execution-log.md`;显式 `harness_events.py render` 随时从完整 events 重建;`harness_archive.py finalize` 在 collect 前强制 render 一次。高频 command append 期间 log 可能滞后,phase 边界保持最新。
|