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,246 +1,246 @@
|
|
|
1
|
-
---
|
|
2
|
-
name: harness-knowledge-ingest
|
|
3
|
-
description: "从 .harness/archive 归档整理、同步和维护项目知识索引。适用场景:ingest knowledge、sync knowledge、rebuild knowledge index、promote knowledge、确认知识条目、检查知识库是否过期。"
|
|
4
|
-
argument-hint: "auto | sync | ingest | audit | promote <entry-id> | demote <entry-id> | mcp"
|
|
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-knowledge-ingest
|
|
25
|
-
|
|
26
|
-
从 `.harness/archive/**/reports/final/summary-data.json` 抽取项目知识,生成并维护本地 `.harness/knowledge/` 索引。
|
|
27
|
-
|
|
28
|
-
当前实现是本地、离线、无 LLM、无外部服务的 SQLite FTS MVP,已经支持基础生命周期:`candidate`、`stale`、`active`、`superseded`、`conflicted`。按新需求查询历史由独立的 `harness-knowledge-query` 负责。
|
|
29
|
-
|
|
30
|
-
## Triggers
|
|
31
|
-
|
|
32
|
-
- ingest knowledge
|
|
33
|
-
- sync knowledge
|
|
34
|
-
- rebuild knowledge index
|
|
35
|
-
- promote knowledge
|
|
36
|
-
- 确认知识条目
|
|
37
|
-
- 从归档生成知识索引
|
|
38
|
-
- 刷新项目知识库
|
|
39
|
-
- 检查知识库是否过期
|
|
40
|
-
|
|
41
|
-
## Required context
|
|
42
|
-
|
|
43
|
-
- AGENTS.md / CLAUDE.md
|
|
44
|
-
- `.harness/archive/**/reports/final/summary-data.json`
|
|
45
|
-
- `.harness/knowledge/index.json`
|
|
46
|
-
- `.harness/codebase/map-summary.md`(如存在)
|
|
47
|
-
- design.md
|
|
48
|
-
|
|
49
|
-
## Purpose
|
|
50
|
-
|
|
51
|
-
解决两个问题:
|
|
52
|
-
|
|
53
|
-
1. **整理知识库内容**:把归档里的 `businessGoal`、`changedFiles`、`maintenanceNotes`、`knownRisks`、`manualActions`、`verification`、`reviewSummary` 抽成知识条目。
|
|
54
|
-
2. **维护知识生命周期**:检查索引是否过期,保留 active 条目;高价值 candidate 可经人工确认提升,也可由 `auto` 首次写入的 `autoPromote` 配置按置信度门槛自动提升。
|
|
55
|
-
|
|
56
|
-
## Outputs
|
|
57
|
-
|
|
58
|
-
```text
|
|
59
|
-
.harness/knowledge/index.json
|
|
60
|
-
.harness/knowledge/index.sqlite
|
|
61
|
-
.harness/knowledge/entries/candidate/*.json
|
|
62
|
-
.harness/knowledge/entries/active/*.json
|
|
63
|
-
.harness/knowledge/entries/stale/*.json
|
|
64
|
-
.harness/knowledge/entries/superseded/*.json
|
|
65
|
-
.harness/knowledge/entries/conflicted/*.json
|
|
66
|
-
.harness/knowledge/cache/archive-entries/*.json
|
|
67
|
-
.harness/knowledge/reports/ingest-report-YYYYMMDD-HHmmss.md
|
|
68
|
-
.harness/knowledge/reports/verification-report-YYYYMMDD-HHmmss.md
|
|
69
|
-
.harness/knowledge/reports/validator-suggestions-YYYYMMDD-HHmmss.md
|
|
70
|
-
.harness/knowledge/reports/audit-report-YYYYMMDD-HHmmss.md
|
|
71
|
-
.harness/knowledge/views/knowledge-dashboard.md
|
|
72
|
-
.harness/knowledge/views/by-file.md
|
|
73
|
-
.harness/knowledge/views/stale-items.md
|
|
74
|
-
.harness/knowledge/views/superseded-items.md
|
|
75
|
-
.harness/knowledge/views/conflicted-items.md
|
|
76
|
-
.harness/knowledge/views/active-review.md
|
|
77
|
-
.harness/knowledge/views/knowledge.base
|
|
78
|
-
.harness/knowledge/context-packs/*.md
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
## Commands
|
|
82
|
-
|
|
83
|
-
`<skill-dir>` 指本 skill 目录。所有 python 脚本命令通过 `powershell.exe -Command "..."` 执行。完整命令示例与 config.json 配置见 `reference.md`「Commands 详细」。
|
|
84
|
-
|
|
85
|
-
| 命令 | 用途 |
|
|
86
|
-
|---|---|
|
|
87
|
-
| `auto` | 一键防腐:首建 config、sync --update、suggest-validators、verify、audit;首次自动写 autoPromote 配置并提升高 confidence 条目 |
|
|
88
|
-
| `ingest` | 重建/刷新知识索引,抽取 candidate;`--no-incremental` 强制全量重抽取 |
|
|
89
|
-
| `sync` | 检查 index 与 archive/HEAD 一致性;`--update` 自动刷新 |
|
|
90
|
-
| `promote` | candidate→active(人工确认或 autoPromote 触发) |
|
|
91
|
-
| `demote` | active→stale/candidate(人工复核后) |
|
|
92
|
-
| `audit` | 生成 Candidate/Stale/Superseded/Conflict/Active Review 报告 |
|
|
93
|
-
| `verify` | 执行 entry validators,刷新 lifecycle.validation,生成 verification-report |
|
|
94
|
-
| `suggest-validators` | 生成 file_exists/file_contains validator 建议;`--apply` 写回 entry |
|
|
95
|
-
| `mcp` | FastMCP stdio 入口,暴露 9 个工具(见 reference.md) |
|
|
96
|
-
|
|
97
|
-
config.json 配置项(autoPromote / confidence / activeLifecycle / knowledgeValidation)详见 `reference.md`「Commands 详细」。
|
|
98
|
-
|
|
99
|
-
## Workflow
|
|
100
|
-
|
|
101
|
-
### Phase 0:确认项目根目录
|
|
102
|
-
|
|
103
|
-
项目根目录必须包含 `.harness/`。如果 `.harness/archive/` 不存在或没有 `summary-data.json`,报告当前项目暂无可索引归档,不要伪造知识。
|
|
104
|
-
|
|
105
|
-
### Phase 1:重建本地知识索引
|
|
106
|
-
|
|
107
|
-
运行:
|
|
108
|
-
|
|
109
|
-
```powershell
|
|
110
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' ingest --project '<project-root>'"
|
|
111
|
-
```
|
|
112
|
-
|
|
113
|
-
生成:
|
|
114
|
-
|
|
115
|
-
- `index.json`:人类可读 manifest。
|
|
116
|
-
- `index.sqlite`:SQLite FTS5 检索索引。
|
|
117
|
-
- `entries/candidate/`:自动抽取、待确认知识。
|
|
118
|
-
- `entries/stale/`:来源 commit 缺失、无法比较,或来源 commit 后相关文件变化的知识。
|
|
119
|
-
- `entries/active/`:人工确认后可长期引用的知识。
|
|
120
|
-
- `views/`:Obsidian 友好的浏览视图。
|
|
121
|
-
- `reports/`:本次 ingest 报告。
|
|
122
|
-
|
|
123
|
-
### Phase 2:同步检查
|
|
124
|
-
|
|
125
|
-
```powershell
|
|
126
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' sync --project '<project-root>'"
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
当 `upToDate=false` 时,应优先运行 `sync --update` 或 `ingest`,再交给 `harness-knowledge-query` 查询。
|
|
130
|
-
|
|
131
|
-
### Phase 3:人工确认高价值知识
|
|
132
|
-
|
|
133
|
-
如果某条 candidate 已确认仍然有效,并且会反复影响后续需求,可运行 `promote` 将其提升为 active。
|
|
134
|
-
|
|
135
|
-
active 条目适合保存:
|
|
136
|
-
|
|
137
|
-
- 需求约束
|
|
138
|
-
- 架构决策
|
|
139
|
-
- API contract
|
|
140
|
-
- 反复踩坑点
|
|
141
|
-
- 测试或发布前置条件
|
|
142
|
-
|
|
143
|
-
不要把一次性实现细节、过期临时方案、未验证结论提升为 active。
|
|
144
|
-
|
|
145
|
-
### Phase 4:解释同步结果
|
|
146
|
-
|
|
147
|
-
回复用户或交给后续 skill 前,应说明:
|
|
148
|
-
|
|
149
|
-
- 索引是否最新。
|
|
150
|
-
- 如需刷新,具体原因是 archive 增删、checksum 变化、sqlite 缺失,还是 HEAD 改变。
|
|
151
|
-
- 本次是否自动刷新。
|
|
152
|
-
- 当前 `active` / `candidate` / `stale` 的数量。
|
|
153
|
-
|
|
154
|
-
## Knowledge extraction rules
|
|
155
|
-
|
|
156
|
-
- Detect duplicate IDs, duplicate content, and conflicting active facts.
|
|
157
|
-
- Keep project-local entries excluded from any global index unless explicitly selected.
|
|
158
|
-
- Validate lifecycle relationships.
|
|
159
|
-
- Default generated entries are `candidate`; only config-gated `autoPromote` may promote high-confidence long-lived entries to `active`.
|
|
160
|
-
- Preserve provenance: every entry must include source archive, summary path, source commit, and source files when available.
|
|
161
|
-
- Do not edit `.harness/archive/**` during ingest.
|
|
162
|
-
- Do not copy secrets into `.harness/knowledge`.
|
|
163
|
-
|
|
164
|
-
## Lifecycle rules
|
|
165
|
-
|
|
166
|
-
- `candidate`:自动抽取但未人工确认。
|
|
167
|
-
- `active`:人工确认、显式 promote,或配置允许的高置信度 autoPromote 后可用。
|
|
168
|
-
- `stale`:来源 commit 缺失、来源 commit 后相关文件变化,或当前代码无法证明旧结论仍有效。
|
|
169
|
-
- `superseded`:被后续归档/决策取代。
|
|
170
|
-
- `conflicted`:与另一条 active/candidate 知识冲突。
|
|
171
|
-
|
|
172
|
-
## Forbidden actions
|
|
173
|
-
|
|
174
|
-
- auto_promote_candidate_knowledge_without_config_and_confidence_gate
|
|
175
|
-
- erase_conflicts
|
|
176
|
-
- include_project_local_by_default
|
|
177
|
-
- mutate_archive_evidence
|
|
178
|
-
- store_secrets
|
|
179
|
-
- treat_stale_knowledge_as_current_fact
|
|
180
|
-
|
|
181
|
-
## Allowed capabilities
|
|
182
|
-
|
|
183
|
-
- read
|
|
184
|
-
- search
|
|
185
|
-
- write_candidate_knowledge
|
|
186
|
-
- write_active_knowledge_after_manual_confirmation
|
|
187
|
-
- write_confidence_scores
|
|
188
|
-
- auto_promote_high_confidence_knowledge_when_configured
|
|
189
|
-
- write_knowledge_index
|
|
190
|
-
- write_obsidian_views
|
|
191
|
-
|
|
192
|
-
## Verification
|
|
193
|
-
|
|
194
|
-
本 skill 自带最小测试:
|
|
195
|
-
|
|
196
|
-
```powershell
|
|
197
|
-
powershell.exe -Command "python -m unittest '<skill-dir>\tests\test_harness_knowledge.py'"
|
|
198
|
-
```
|
|
199
|
-
|
|
200
|
-
完成脚本修改后必须至少运行该测试。若在真实项目中验证,还应运行:
|
|
201
|
-
|
|
202
|
-
```powershell
|
|
203
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' auto --project '<real-project-root>'"
|
|
204
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' ingest --project '<real-project-root>'"
|
|
205
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' suggest-validators --project '<real-project-root>' --limit 20"
|
|
206
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' verify --project '<real-project-root>'"
|
|
207
|
-
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' sync --project '<real-project-root>'"
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
并确认 `index.json`、`index.sqlite`、`views/knowledge-dashboard.md`、`reports/verification-report-*.md` 存在,且 sync 输出 `upToDate=true`。
|
|
211
|
-
|
|
212
|
-
## P0 执行可信度规则
|
|
213
|
-
|
|
214
|
-
- 命令结果不得靠猜测;普通 Bash 被拒 → 立即改用等价 PowerShell 重试一次
|
|
215
|
-
- 仅 PowerShell 成功且有明确证据(构建/git/测试输出、文件存在、exit 0)时可标 ✅OK;否则 ❌FAIL 或 🟡WARN
|
|
216
|
-
- 禁止把 hook 拒绝、静态验证、无输出、用户跳过说成成功 → 详见 [[../protocols/powershell-protocol.md|powershell-protocol]]、[[../protocols/evidence-based-reporting-protocol.md|evidence-based-reporting-protocol]]
|
|
217
|
-
|
|
218
|
-
## Output Format
|
|
219
|
-
|
|
220
|
-
执行完成后展示:
|
|
221
|
-
|
|
222
|
-
- 本次命令(ingest/sync/promote)与目标项目根。
|
|
223
|
-
- `upToDate` 及 `reasons`(sync)或新增/覆盖条目数(ingest/promote)。
|
|
224
|
-
- 当前 `active` / `candidate` / `stale` 数量统计。
|
|
225
|
-
- 产物路径(`index.json`、`index.sqlite`、`views/`、`reports/`)。
|
|
226
|
-
- 下一步建议(`upToDate=false` → `sync --update`;有 candidate → 人工确认后 `promote`,或项目启用 `autoPromote` 后让高置信度长期知识自动提升;查询历史 → `/harness-knowledge-query`)。
|
|
227
|
-
|
|
228
|
-
## 渐进披露
|
|
229
|
-
|
|
230
|
-
- **Read `reference.md`** 仅在执行命令或查阅 config.json 配置时 — 含 Commands 详细示例(9 命令的 powershell 示例 + config.json 配置)与变更日志(v1.7–v1.13 补充能力)。
|
|
231
|
-
|
|
232
|
-
## 交互白名单
|
|
233
|
-
|
|
234
|
-
**仅当** `.harness/config/harness.json` 中 `knowledge.manualReview=true` 时,promote/demote 高价值条目需 AskUserQuestion;否则按 skill 默认策略 + `decision` 事件。
|
|
235
|
-
|
|
236
|
-
## 执行日志
|
|
237
|
-
|
|
238
|
-
`events.ndjson` 为唯一事实源(schema_version 2,`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止手工 Edit**。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
|
|
239
|
-
|
|
240
|
-
```powershell
|
|
241
|
-
python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
> **脚本接线**:`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 护栏解读。
|
|
245
|
-
|
|
246
|
-
> **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-knowledge-ingest
|
|
3
|
+
description: "从 .harness/archive 归档整理、同步和维护项目知识索引。适用场景:ingest knowledge、sync knowledge、rebuild knowledge index、promote knowledge、确认知识条目、检查知识库是否过期。"
|
|
4
|
+
argument-hint: "auto | sync | ingest | audit | promote <entry-id> | demote <entry-id> | mcp"
|
|
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-knowledge-ingest
|
|
25
|
+
|
|
26
|
+
从 `.harness/archive/**/reports/final/summary-data.json` 抽取项目知识,生成并维护本地 `.harness/knowledge/` 索引。
|
|
27
|
+
|
|
28
|
+
当前实现是本地、离线、无 LLM、无外部服务的 SQLite FTS MVP,已经支持基础生命周期:`candidate`、`stale`、`active`、`superseded`、`conflicted`。按新需求查询历史由独立的 `harness-knowledge-query` 负责。
|
|
29
|
+
|
|
30
|
+
## Triggers
|
|
31
|
+
|
|
32
|
+
- ingest knowledge
|
|
33
|
+
- sync knowledge
|
|
34
|
+
- rebuild knowledge index
|
|
35
|
+
- promote knowledge
|
|
36
|
+
- 确认知识条目
|
|
37
|
+
- 从归档生成知识索引
|
|
38
|
+
- 刷新项目知识库
|
|
39
|
+
- 检查知识库是否过期
|
|
40
|
+
|
|
41
|
+
## Required context
|
|
42
|
+
|
|
43
|
+
- AGENTS.md / CLAUDE.md
|
|
44
|
+
- `.harness/archive/**/reports/final/summary-data.json`
|
|
45
|
+
- `.harness/knowledge/index.json`
|
|
46
|
+
- `.harness/codebase/map-summary.md`(如存在)
|
|
47
|
+
- design.md
|
|
48
|
+
|
|
49
|
+
## Purpose
|
|
50
|
+
|
|
51
|
+
解决两个问题:
|
|
52
|
+
|
|
53
|
+
1. **整理知识库内容**:把归档里的 `businessGoal`、`changedFiles`、`maintenanceNotes`、`knownRisks`、`manualActions`、`verification`、`reviewSummary` 抽成知识条目。
|
|
54
|
+
2. **维护知识生命周期**:检查索引是否过期,保留 active 条目;高价值 candidate 可经人工确认提升,也可由 `auto` 首次写入的 `autoPromote` 配置按置信度门槛自动提升。
|
|
55
|
+
|
|
56
|
+
## Outputs
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
.harness/knowledge/index.json
|
|
60
|
+
.harness/knowledge/index.sqlite
|
|
61
|
+
.harness/knowledge/entries/candidate/*.json
|
|
62
|
+
.harness/knowledge/entries/active/*.json
|
|
63
|
+
.harness/knowledge/entries/stale/*.json
|
|
64
|
+
.harness/knowledge/entries/superseded/*.json
|
|
65
|
+
.harness/knowledge/entries/conflicted/*.json
|
|
66
|
+
.harness/knowledge/cache/archive-entries/*.json
|
|
67
|
+
.harness/knowledge/reports/ingest-report-YYYYMMDD-HHmmss.md
|
|
68
|
+
.harness/knowledge/reports/verification-report-YYYYMMDD-HHmmss.md
|
|
69
|
+
.harness/knowledge/reports/validator-suggestions-YYYYMMDD-HHmmss.md
|
|
70
|
+
.harness/knowledge/reports/audit-report-YYYYMMDD-HHmmss.md
|
|
71
|
+
.harness/knowledge/views/knowledge-dashboard.md
|
|
72
|
+
.harness/knowledge/views/by-file.md
|
|
73
|
+
.harness/knowledge/views/stale-items.md
|
|
74
|
+
.harness/knowledge/views/superseded-items.md
|
|
75
|
+
.harness/knowledge/views/conflicted-items.md
|
|
76
|
+
.harness/knowledge/views/active-review.md
|
|
77
|
+
.harness/knowledge/views/knowledge.base
|
|
78
|
+
.harness/knowledge/context-packs/*.md
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Commands
|
|
82
|
+
|
|
83
|
+
`<skill-dir>` 指本 skill 目录。所有 python 脚本命令通过 `powershell.exe -Command "..."` 执行。完整命令示例与 config.json 配置见 `reference.md`「Commands 详细」。
|
|
84
|
+
|
|
85
|
+
| 命令 | 用途 |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `auto` | 一键防腐:首建 config、sync --update、suggest-validators、verify、audit;首次自动写 autoPromote 配置并提升高 confidence 条目 |
|
|
88
|
+
| `ingest` | 重建/刷新知识索引,抽取 candidate;`--no-incremental` 强制全量重抽取 |
|
|
89
|
+
| `sync` | 检查 index 与 archive/HEAD 一致性;`--update` 自动刷新 |
|
|
90
|
+
| `promote` | candidate→active(人工确认或 autoPromote 触发) |
|
|
91
|
+
| `demote` | active→stale/candidate(人工复核后) |
|
|
92
|
+
| `audit` | 生成 Candidate/Stale/Superseded/Conflict/Active Review 报告 |
|
|
93
|
+
| `verify` | 执行 entry validators,刷新 lifecycle.validation,生成 verification-report |
|
|
94
|
+
| `suggest-validators` | 生成 file_exists/file_contains validator 建议;`--apply` 写回 entry |
|
|
95
|
+
| `mcp` | FastMCP stdio 入口,暴露 9 个工具(见 reference.md) |
|
|
96
|
+
|
|
97
|
+
config.json 配置项(autoPromote / confidence / activeLifecycle / knowledgeValidation)详见 `reference.md`「Commands 详细」。
|
|
98
|
+
|
|
99
|
+
## Workflow
|
|
100
|
+
|
|
101
|
+
### Phase 0:确认项目根目录
|
|
102
|
+
|
|
103
|
+
项目根目录必须包含 `.harness/`。如果 `.harness/archive/` 不存在或没有 `summary-data.json`,报告当前项目暂无可索引归档,不要伪造知识。
|
|
104
|
+
|
|
105
|
+
### Phase 1:重建本地知识索引
|
|
106
|
+
|
|
107
|
+
运行:
|
|
108
|
+
|
|
109
|
+
```powershell
|
|
110
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' ingest --project '<project-root>'"
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
生成:
|
|
114
|
+
|
|
115
|
+
- `index.json`:人类可读 manifest。
|
|
116
|
+
- `index.sqlite`:SQLite FTS5 检索索引。
|
|
117
|
+
- `entries/candidate/`:自动抽取、待确认知识。
|
|
118
|
+
- `entries/stale/`:来源 commit 缺失、无法比较,或来源 commit 后相关文件变化的知识。
|
|
119
|
+
- `entries/active/`:人工确认后可长期引用的知识。
|
|
120
|
+
- `views/`:Obsidian 友好的浏览视图。
|
|
121
|
+
- `reports/`:本次 ingest 报告。
|
|
122
|
+
|
|
123
|
+
### Phase 2:同步检查
|
|
124
|
+
|
|
125
|
+
```powershell
|
|
126
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' sync --project '<project-root>'"
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
当 `upToDate=false` 时,应优先运行 `sync --update` 或 `ingest`,再交给 `harness-knowledge-query` 查询。
|
|
130
|
+
|
|
131
|
+
### Phase 3:人工确认高价值知识
|
|
132
|
+
|
|
133
|
+
如果某条 candidate 已确认仍然有效,并且会反复影响后续需求,可运行 `promote` 将其提升为 active。
|
|
134
|
+
|
|
135
|
+
active 条目适合保存:
|
|
136
|
+
|
|
137
|
+
- 需求约束
|
|
138
|
+
- 架构决策
|
|
139
|
+
- API contract
|
|
140
|
+
- 反复踩坑点
|
|
141
|
+
- 测试或发布前置条件
|
|
142
|
+
|
|
143
|
+
不要把一次性实现细节、过期临时方案、未验证结论提升为 active。
|
|
144
|
+
|
|
145
|
+
### Phase 4:解释同步结果
|
|
146
|
+
|
|
147
|
+
回复用户或交给后续 skill 前,应说明:
|
|
148
|
+
|
|
149
|
+
- 索引是否最新。
|
|
150
|
+
- 如需刷新,具体原因是 archive 增删、checksum 变化、sqlite 缺失,还是 HEAD 改变。
|
|
151
|
+
- 本次是否自动刷新。
|
|
152
|
+
- 当前 `active` / `candidate` / `stale` 的数量。
|
|
153
|
+
|
|
154
|
+
## Knowledge extraction rules
|
|
155
|
+
|
|
156
|
+
- Detect duplicate IDs, duplicate content, and conflicting active facts.
|
|
157
|
+
- Keep project-local entries excluded from any global index unless explicitly selected.
|
|
158
|
+
- Validate lifecycle relationships.
|
|
159
|
+
- Default generated entries are `candidate`; only config-gated `autoPromote` may promote high-confidence long-lived entries to `active`.
|
|
160
|
+
- Preserve provenance: every entry must include source archive, summary path, source commit, and source files when available.
|
|
161
|
+
- Do not edit `.harness/archive/**` during ingest.
|
|
162
|
+
- Do not copy secrets into `.harness/knowledge`.
|
|
163
|
+
|
|
164
|
+
## Lifecycle rules
|
|
165
|
+
|
|
166
|
+
- `candidate`:自动抽取但未人工确认。
|
|
167
|
+
- `active`:人工确认、显式 promote,或配置允许的高置信度 autoPromote 后可用。
|
|
168
|
+
- `stale`:来源 commit 缺失、来源 commit 后相关文件变化,或当前代码无法证明旧结论仍有效。
|
|
169
|
+
- `superseded`:被后续归档/决策取代。
|
|
170
|
+
- `conflicted`:与另一条 active/candidate 知识冲突。
|
|
171
|
+
|
|
172
|
+
## Forbidden actions
|
|
173
|
+
|
|
174
|
+
- auto_promote_candidate_knowledge_without_config_and_confidence_gate
|
|
175
|
+
- erase_conflicts
|
|
176
|
+
- include_project_local_by_default
|
|
177
|
+
- mutate_archive_evidence
|
|
178
|
+
- store_secrets
|
|
179
|
+
- treat_stale_knowledge_as_current_fact
|
|
180
|
+
|
|
181
|
+
## Allowed capabilities
|
|
182
|
+
|
|
183
|
+
- read
|
|
184
|
+
- search
|
|
185
|
+
- write_candidate_knowledge
|
|
186
|
+
- write_active_knowledge_after_manual_confirmation
|
|
187
|
+
- write_confidence_scores
|
|
188
|
+
- auto_promote_high_confidence_knowledge_when_configured
|
|
189
|
+
- write_knowledge_index
|
|
190
|
+
- write_obsidian_views
|
|
191
|
+
|
|
192
|
+
## Verification
|
|
193
|
+
|
|
194
|
+
本 skill 自带最小测试:
|
|
195
|
+
|
|
196
|
+
```powershell
|
|
197
|
+
powershell.exe -Command "python -m unittest '<skill-dir>\tests\test_harness_knowledge.py'"
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
完成脚本修改后必须至少运行该测试。若在真实项目中验证,还应运行:
|
|
201
|
+
|
|
202
|
+
```powershell
|
|
203
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' auto --project '<real-project-root>'"
|
|
204
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' ingest --project '<real-project-root>'"
|
|
205
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' suggest-validators --project '<real-project-root>' --limit 20"
|
|
206
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' verify --project '<real-project-root>'"
|
|
207
|
+
powershell.exe -Command "python '<skill-dir>\scripts\harness_knowledge.py' sync --project '<real-project-root>'"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
并确认 `index.json`、`index.sqlite`、`views/knowledge-dashboard.md`、`reports/verification-report-*.md` 存在,且 sync 输出 `upToDate=true`。
|
|
211
|
+
|
|
212
|
+
## P0 执行可信度规则
|
|
213
|
+
|
|
214
|
+
- 命令结果不得靠猜测;普通 Bash 被拒 → 立即改用等价 PowerShell 重试一次
|
|
215
|
+
- 仅 PowerShell 成功且有明确证据(构建/git/测试输出、文件存在、exit 0)时可标 ✅OK;否则 ❌FAIL 或 🟡WARN
|
|
216
|
+
- 禁止把 hook 拒绝、静态验证、无输出、用户跳过说成成功 → 详见 [[../protocols/powershell-protocol.md|powershell-protocol]]、[[../protocols/evidence-based-reporting-protocol.md|evidence-based-reporting-protocol]]
|
|
217
|
+
|
|
218
|
+
## Output Format
|
|
219
|
+
|
|
220
|
+
执行完成后展示:
|
|
221
|
+
|
|
222
|
+
- 本次命令(ingest/sync/promote)与目标项目根。
|
|
223
|
+
- `upToDate` 及 `reasons`(sync)或新增/覆盖条目数(ingest/promote)。
|
|
224
|
+
- 当前 `active` / `candidate` / `stale` 数量统计。
|
|
225
|
+
- 产物路径(`index.json`、`index.sqlite`、`views/`、`reports/`)。
|
|
226
|
+
- 下一步建议(`upToDate=false` → `sync --update`;有 candidate → 人工确认后 `promote`,或项目启用 `autoPromote` 后让高置信度长期知识自动提升;查询历史 → `/harness-knowledge-query`)。
|
|
227
|
+
|
|
228
|
+
## 渐进披露
|
|
229
|
+
|
|
230
|
+
- **Read `reference.md`** 仅在执行命令或查阅 config.json 配置时 — 含 Commands 详细示例(9 命令的 powershell 示例 + config.json 配置)与变更日志(v1.7–v1.13 补充能力)。
|
|
231
|
+
|
|
232
|
+
## 交互白名单
|
|
233
|
+
|
|
234
|
+
**仅当** `.harness/config/harness.json` 中 `knowledge.manualReview=true` 时,promote/demote 高价值条目需 AskUserQuestion;否则按 skill 默认策略 + `decision` 事件。
|
|
235
|
+
|
|
236
|
+
## 执行日志
|
|
237
|
+
|
|
238
|
+
`events.ndjson` 为唯一事实源(schema_version 2,`note` 承载人类可读摘要);`logs/execution-log.md` 由 `harness_events.py` 渲染,**禁止手工 Edit**。结构 → [[../protocols/report-pipeline-protocol.md|report-pipeline-protocol]]
|
|
239
|
+
|
|
240
|
+
```powershell
|
|
241
|
+
python <skills-root>/scripts/harness_events.py append --change-dir ".harness/changes/<change-name>" --phase <phase> --type phase.start --note "<触发指令>"
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
> **脚本接线**:`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 护栏解读。
|
|
245
|
+
|
|
246
|
+
> **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 边界保持最新。
|