@erzhe/harness-kit 0.1.2 → 0.1.3
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/README.md +20 -4
- package/SPEC-v0.md +0 -2
- package/dist/harness-kit.cjs +4 -17
- package/package.json +1 -1
- package/skills/erzhe-harness-init/SKILL.md +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> 给 Agent 发一句话,让它帮你把仓库变成 AI 友好的。
|
|
4
4
|
|
|
5
|
-
harness-kit 把仓库的工程知识(这是什么、怎么跑、什么不能破、改东西看哪)沉淀成一份 `.agents/manifest.yaml`,然后自动生成各家 Agent 的入口文件(`AGENTS.md` / `CLAUDE.md
|
|
5
|
+
harness-kit 把仓库的工程知识(这是什么、怎么跑、什么不能破、改东西看哪)沉淀成一份 `.agents/manifest.yaml`,然后自动生成各家 Agent 的入口文件(`AGENTS.md` / `CLAUDE.md`),并用门禁保证它们始终一致。
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
@@ -20,6 +20,7 @@ Onboard 本仓库到 harness-kit:跑 npx -y @erzhe/harness-kit@latest onboard
|
|
|
20
20
|
2. 扫描你的仓库(读 README、package.json、目录结构…)
|
|
21
21
|
3. 逐块跟你确认着填 `.agents/manifest.yaml`
|
|
22
22
|
4. 跑 `sync` / `doctor` / `verify` 直到全绿
|
|
23
|
+
5. 装上 git 钩子(`install-hooks`):之后 pre-commit 自动 sync、pre-push verify 拦漂移,维护不用你记命令
|
|
23
24
|
|
|
24
25
|
全程走 `npx`,不往机器上装任何全局东西;你一发新版,所有人下次执行就用上了。
|
|
25
26
|
|
|
@@ -31,7 +32,6 @@ Onboard 本仓库到 harness-kit:跑 npx -y @erzhe/harness-kit@latest onboard
|
|
|
31
32
|
你的仓库/
|
|
32
33
|
AGENTS.md ← [生成] 跨工具入口,Agent 每次会话必读
|
|
33
34
|
CLAUDE.md ← [生成] Claude Code 入口
|
|
34
|
-
.cursor/rules/ ← [生成] Cursor 规则
|
|
35
35
|
.agents/
|
|
36
36
|
manifest.yaml ← 你维护的唯一真相源
|
|
37
37
|
knowledge/ ← Agent 从代码推不出来的知识(领域、约定、决策)
|
|
@@ -45,13 +45,29 @@ Onboard 本仓库到 harness-kit:跑 npx -y @erzhe/harness-kit@latest onboard
|
|
|
45
45
|
|
|
46
46
|
---
|
|
47
47
|
|
|
48
|
+
## 接入之后:自动防腐烂,人只 review
|
|
49
|
+
|
|
50
|
+
harness-kit 的长期价值不在首次接入,而在**代码演进时上下文不腐烂**——而且这件事不该靠人记命令:
|
|
51
|
+
|
|
52
|
+
- **装了钩子就无感**:`install-hooks` 之后,pre-commit 自动重生成入口文件、pre-push 跑 `verify`,上下文和代码对不上就红灯拦下。
|
|
53
|
+
- **漂移了让 Agent 自愈**:知识过期 / 接口契约变了,把仓库丢给 Agent 说一句 `onboard`,它会照 skill 自动考古、改 manifest/knowledge、有据才 accept 契约,最后**产出一份变更清单**。
|
|
54
|
+
- **你只做一个动作**:审查那份 diff,批准或打回。生产和更新都交给 Agent,人只 review。
|
|
55
|
+
|
|
56
|
+
```
|
|
57
|
+
代码演进 → [hook/CI] verify 红灯,指出哪块过期/哪个契约变了
|
|
58
|
+
→ [Agent] 自动修 + 产出变更清单
|
|
59
|
+
→ [你] review:批准 or 打回 ← 唯一的人工动作
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
48
64
|
## 命令
|
|
49
65
|
|
|
50
66
|
| 命令 | 作用 |
|
|
51
67
|
| --- | --- |
|
|
52
68
|
| `harness-kit onboard` | 打印 onboard skill 给 Agent(配合 npx,永远最新、零安装) |
|
|
53
69
|
| `harness-kit init` | 铺 `.agents/` 骨架 + 空白 manifest |
|
|
54
|
-
| `harness-kit sync` | manifest → 生成 AGENTS.md / CLAUDE.md /
|
|
70
|
+
| `harness-kit sync` | manifest → 生成 AGENTS.md / CLAUDE.md / routing / modules |
|
|
55
71
|
| `harness-kit doctor` | 体检:完整性 / 路径引用 / 漂移 / 新鲜度 / 体量预算 |
|
|
56
72
|
| `harness-kit verify` | 门禁:跑不变量 + 契约 + 漂移,列出 GAPS,失败非 0 退出 |
|
|
57
73
|
| `harness-kit accept-contract` | 有意变更接口后,记录新的契约指纹为基线 |
|
|
@@ -82,7 +98,7 @@ harness-kit 把这些沉淀进 manifest,再确定性地生成与校验。
|
|
|
82
98
|
│
|
|
83
99
|
harness-kit sync (确定性生成,勿手改产物)
|
|
84
100
|
▼
|
|
85
|
-
AGENTS.md / CLAUDE.md / .
|
|
101
|
+
AGENTS.md / CLAUDE.md / .agents/routing.md / .agents/modules.md
|
|
86
102
|
│
|
|
87
103
|
harness-kit verify (门禁:不变量 + 契约 + 漂移)
|
|
88
104
|
▼
|
package/SPEC-v0.md
CHANGED
|
@@ -29,7 +29,6 @@
|
|
|
29
29
|
<repo>/
|
|
30
30
|
AGENTS.md # [生成] 跨工具入口,<100 行,指路
|
|
31
31
|
CLAUDE.md # [生成] 首行 @AGENTS.md
|
|
32
|
-
.cursor/rules/00-follow-agents.mdc # [生成] 薄适配器
|
|
33
32
|
.agents/ # canonical 命名空间(唯一手写源)
|
|
34
33
|
manifest.yaml # 脊椎(本规范核心,见 §3)
|
|
35
34
|
knowledge/ # 手写叙述:domain / conventions / journal
|
|
@@ -142,7 +141,6 @@ playbooks:
|
|
|
142
141
|
generate:
|
|
143
142
|
- to: "AGENTS.md" render: "identity+capabilities+environment+invariants"
|
|
144
143
|
- to: "CLAUDE.md" content: "@AGENTS.md"
|
|
145
|
-
- to: ".cursor/rules/00-follow-agents.mdc" template: "adapter"
|
|
146
144
|
```
|
|
147
145
|
|
|
148
146
|
**保留动词说明**:`capabilities` 的保留动词全部**可选**——它是一套"共享词汇表",仓库只声明适用的子集(库通常没有 `run`;前端 `run` 是 dev server 且 `background: true`)。Agent 冷启动时能预期这些词的语义。
|
package/dist/harness-kit.cjs
CHANGED
|
@@ -16663,8 +16663,7 @@ function validateManifest(m) {
|
|
|
16663
16663
|
function renderTargets(m) {
|
|
16664
16664
|
const targets = [
|
|
16665
16665
|
["AGENTS.md", renderAgentsMd(m)],
|
|
16666
|
-
["CLAUDE.md", renderClaudeMd()]
|
|
16667
|
-
[".cursor/rules/00-follow-agents.mdc", renderCursorRule()]
|
|
16666
|
+
["CLAUDE.md", renderClaudeMd()]
|
|
16668
16667
|
];
|
|
16669
16668
|
if (m.routing?.length) targets.push([".agents/routing.md", renderRoutingMd(m)]);
|
|
16670
16669
|
if (m.modules?.length) targets.push([".agents/modules.md", renderModulesMd(m)]);
|
|
@@ -16789,18 +16788,6 @@ function renderClaudeMd() {
|
|
|
16789
16788
|
${GEN_HEADER()}
|
|
16790
16789
|
`;
|
|
16791
16790
|
}
|
|
16792
|
-
function renderCursorRule() {
|
|
16793
|
-
return `---
|
|
16794
|
-
description: Follow the repo AGENTS.md (generated from .agents/manifest.yaml)
|
|
16795
|
-
alwaysApply: true
|
|
16796
|
-
---
|
|
16797
|
-
${GEN_HEADER()}
|
|
16798
|
-
|
|
16799
|
-
Read \`AGENTS.md\` at the repo root for project scope, commands, environment,
|
|
16800
|
-
contracts, and invariants. It is the single source of truth (generated).
|
|
16801
|
-
Do not edit generated files; edit \`.agents/manifest.yaml\` then run \`harness-kit sync\`.
|
|
16802
|
-
`;
|
|
16803
|
-
}
|
|
16804
16791
|
|
|
16805
16792
|
// src/state.ts
|
|
16806
16793
|
var import_node_path5 = require("node:path");
|
|
@@ -17184,7 +17171,7 @@ if ! $HK sync --repo . >/dev/null; then
|
|
|
17184
17171
|
echo "harness-kit: sync failed (run \\\`$HK sync\\\` to see why)" >&2
|
|
17185
17172
|
exit 1
|
|
17186
17173
|
fi
|
|
17187
|
-
git add AGENTS.md CLAUDE.md .
|
|
17174
|
+
git add AGENTS.md CLAUDE.md .agents >/dev/null 2>&1 || true
|
|
17188
17175
|
exit 0
|
|
17189
17176
|
`;
|
|
17190
17177
|
}
|
|
@@ -17286,10 +17273,10 @@ function guard(fn) {
|
|
|
17286
17273
|
}
|
|
17287
17274
|
}
|
|
17288
17275
|
var program2 = new Command();
|
|
17289
|
-
program2.name("harness-kit").description("AI-friendly repo harness").version("0.1.
|
|
17276
|
+
program2.name("harness-kit").description("AI-friendly repo harness").version("0.1.3");
|
|
17290
17277
|
var repoOf = (o) => (0, import_node_path13.resolve)(o.repo);
|
|
17291
17278
|
program2.command("init").description("scaffold .agents/ skeleton + starter manifest").option("-C, --repo <dir>", "target repo dir", process.cwd()).option("--name <name>", "project name", "my-project").option("--force", "overwrite existing manifest", false).action((o) => guard(() => initCmd(repoOf(o), o.name, o.force)));
|
|
17292
|
-
program2.command("sync").description("generate tool files (AGENTS.md, CLAUDE.md
|
|
17279
|
+
program2.command("sync").description("generate tool files (AGENTS.md, CLAUDE.md) from manifest").option("-C, --repo <dir>", "target repo dir", process.cwd()).action((o) => guard(() => syncCmd(repoOf(o))));
|
|
17293
17280
|
program2.command("doctor").description("dev-time health check: completeness, drift, freshness, tech debt").option("-C, --repo <dir>", "target repo dir", process.cwd()).action((o) => guard(() => doctorCmd(repoOf(o))));
|
|
17294
17281
|
program2.command("verify").description("CI gate: run enforceable invariants + contracts + drift; nonzero on failure").option("-C, --repo <dir>", "target repo dir", process.cwd()).action((o) => guard(() => verifyCmd(repoOf(o))));
|
|
17295
17282
|
program2.command("accept-contract").description("record current contract fingerprint(s) as the accepted baseline (after an intended change)").option("-C, --repo <dir>", "target repo dir", process.cwd()).option("--id <id>", "only this contract (default: all with a snapshot command)").action((o) => guard(() => acceptContractCmd(repoOf(o), o.id)));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@erzhe/harness-kit",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AI-friendly repo harness: a manifest.yaml single source of truth that generates AGENTS.md / CLAUDE.md / Cursor rules and enforces invariants, contracts and drift via `harness-kit verify`.",
|
|
6
6
|
"keywords": [
|
|
@@ -49,7 +49,7 @@ harness-kit init --repo .
|
|
|
49
49
|
## 3. 生成 + 验证到绿
|
|
50
50
|
|
|
51
51
|
```
|
|
52
|
-
harness-kit sync # manifest -> AGENTS.md / CLAUDE.md /
|
|
52
|
+
harness-kit sync # manifest -> AGENTS.md / CLAUDE.md / routing.md / modules.md
|
|
53
53
|
harness-kit doctor # 补全度 / 引用路径 / 漂移 / 新鲜度 / 体量预算;按报告修
|
|
54
54
|
harness-kit verify # 门禁:跑不变量 + 契约 + 漂移,并列出 GAPS
|
|
55
55
|
```
|