@dommaker/harness 0.8.1 → 0.9.0

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 (339) hide show
  1. package/README.md +126 -183
  2. package/bin/harness.js +29 -12
  3. package/dist/agents/index.d.ts +3 -0
  4. package/dist/agents/index.d.ts.map +1 -0
  5. package/dist/agents/index.js +19 -0
  6. package/dist/agents/index.js.map +1 -0
  7. package/dist/agents/lifecycle.d.ts +68 -0
  8. package/dist/agents/lifecycle.d.ts.map +1 -0
  9. package/dist/agents/lifecycle.js +181 -0
  10. package/dist/agents/lifecycle.js.map +1 -0
  11. package/dist/agents/types.d.ts +42 -0
  12. package/dist/agents/types.d.ts.map +1 -0
  13. package/dist/agents/types.js +6 -0
  14. package/dist/agents/types.js.map +1 -0
  15. package/dist/architecture/cross-project-checker.d.ts +19 -1
  16. package/dist/architecture/cross-project-checker.d.ts.map +1 -1
  17. package/dist/architecture/cross-project-checker.js +72 -60
  18. package/dist/architecture/cross-project-checker.js.map +1 -1
  19. package/dist/cli/commands/acceptance.d.ts.map +1 -1
  20. package/dist/cli/commands/acceptance.js +1 -0
  21. package/dist/cli/commands/acceptance.js.map +1 -1
  22. package/dist/cli/commands/check.d.ts.map +1 -1
  23. package/dist/cli/commands/check.js +2 -4
  24. package/dist/cli/commands/check.js.map +1 -1
  25. package/dist/cli/commands/command.d.ts +19 -0
  26. package/dist/cli/commands/command.d.ts.map +1 -0
  27. package/dist/cli/commands/command.js +81 -0
  28. package/dist/cli/commands/command.js.map +1 -0
  29. package/dist/cli/commands/index.d.ts +1 -0
  30. package/dist/cli/commands/index.d.ts.map +1 -1
  31. package/dist/cli/commands/index.js +3 -1
  32. package/dist/cli/commands/index.js.map +1 -1
  33. package/dist/cli/commands/passes-gate.d.ts.map +1 -1
  34. package/dist/cli/commands/passes-gate.js +2 -4
  35. package/dist/cli/commands/passes-gate.js.map +1 -1
  36. package/dist/cli/commands/review.d.ts.map +1 -1
  37. package/dist/cli/commands/review.js +27 -63
  38. package/dist/cli/commands/review.js.map +1 -1
  39. package/dist/cli/commands/security.d.ts +1 -1
  40. package/dist/cli/commands/security.d.ts.map +1 -1
  41. package/dist/cli/commands/security.js +40 -94
  42. package/dist/cli/commands/security.js.map +1 -1
  43. package/dist/cli/commands/status.d.ts.map +1 -1
  44. package/dist/cli/commands/status.js +2 -2
  45. package/dist/cli/commands/status.js.map +1 -1
  46. package/dist/constraints/definitions.d.ts +39 -0
  47. package/dist/constraints/definitions.d.ts.map +1 -0
  48. package/dist/constraints/definitions.js +71 -0
  49. package/dist/constraints/definitions.js.map +1 -0
  50. package/dist/constraints/index.d.ts +5 -0
  51. package/dist/constraints/index.d.ts.map +1 -0
  52. package/dist/constraints/index.js +21 -0
  53. package/dist/constraints/index.js.map +1 -0
  54. package/dist/constraints/quality.d.ts +11 -0
  55. package/dist/constraints/quality.d.ts.map +1 -0
  56. package/dist/constraints/quality.js +257 -0
  57. package/dist/constraints/quality.js.map +1 -0
  58. package/dist/constraints/registry.d.ts +64 -0
  59. package/dist/constraints/registry.d.ts.map +1 -0
  60. package/dist/constraints/registry.js +167 -0
  61. package/dist/constraints/registry.js.map +1 -0
  62. package/dist/constraints/safety.d.ts +13 -0
  63. package/dist/constraints/safety.d.ts.map +1 -0
  64. package/dist/constraints/safety.js +103 -0
  65. package/dist/constraints/safety.js.map +1 -0
  66. package/dist/constraints/types.d.ts +53 -0
  67. package/dist/constraints/types.d.ts.map +1 -0
  68. package/dist/constraints/types.js +8 -0
  69. package/dist/constraints/types.js.map +1 -0
  70. package/dist/context/compaction.d.ts +57 -0
  71. package/dist/context/compaction.d.ts.map +1 -0
  72. package/dist/context/compaction.js +166 -0
  73. package/dist/context/compaction.js.map +1 -0
  74. package/dist/context/file-budget.d.ts +40 -0
  75. package/dist/context/file-budget.d.ts.map +1 -0
  76. package/dist/context/file-budget.js +147 -0
  77. package/dist/context/file-budget.js.map +1 -0
  78. package/dist/context/index.d.ts +15 -0
  79. package/dist/context/index.d.ts.map +1 -0
  80. package/dist/context/index.js +31 -0
  81. package/dist/context/index.js.map +1 -0
  82. package/dist/context/knowledge-injector.d.ts +49 -0
  83. package/dist/context/knowledge-injector.d.ts.map +1 -0
  84. package/dist/context/knowledge-injector.js +122 -0
  85. package/dist/context/knowledge-injector.js.map +1 -0
  86. package/dist/context/progressive-loader.d.ts +0 -1
  87. package/dist/context/progressive-loader.d.ts.map +1 -1
  88. package/dist/context/progressive-loader.js +15 -32
  89. package/dist/context/progressive-loader.js.map +1 -1
  90. package/dist/context/session-manager.d.ts +67 -0
  91. package/dist/context/session-manager.d.ts.map +1 -0
  92. package/dist/context/session-manager.js +275 -0
  93. package/dist/context/session-manager.js.map +1 -0
  94. package/dist/context/token-pipeline.d.ts +55 -0
  95. package/dist/context/token-pipeline.d.ts.map +1 -0
  96. package/dist/context/token-pipeline.js +220 -0
  97. package/dist/context/token-pipeline.js.map +1 -0
  98. package/dist/context/tool-output-budget.d.ts +59 -0
  99. package/dist/context/tool-output-budget.d.ts.map +1 -0
  100. package/dist/context/tool-output-budget.js +177 -0
  101. package/dist/context/tool-output-budget.js.map +1 -0
  102. package/dist/context/types.d.ts +113 -0
  103. package/dist/context/types.d.ts.map +1 -0
  104. package/dist/context/types.js +30 -0
  105. package/dist/context/types.js.map +1 -0
  106. package/dist/core/constraints/checker.d.ts +9 -1
  107. package/dist/core/constraints/checker.d.ts.map +1 -1
  108. package/dist/core/constraints/checker.js +72 -155
  109. package/dist/core/constraints/checker.js.map +1 -1
  110. package/dist/core/constraints/definitions.d.ts.map +1 -1
  111. package/dist/core/constraints/definitions.js +8 -10
  112. package/dist/core/constraints/definitions.js.map +1 -1
  113. package/dist/core/constraints/interceptor.d.ts.map +1 -1
  114. package/dist/core/constraints/interceptor.js +2 -6
  115. package/dist/core/constraints/interceptor.js.map +1 -1
  116. package/dist/core/project-config-loader.d.ts.map +1 -1
  117. package/dist/core/project-config-loader.js +12 -30
  118. package/dist/core/project-config-loader.js.map +1 -1
  119. package/dist/core/session/clean-state.d.ts.map +1 -1
  120. package/dist/core/session/clean-state.js +6 -8
  121. package/dist/core/session/clean-state.js.map +1 -1
  122. package/dist/core/session/startup.d.ts.map +1 -1
  123. package/dist/core/session/startup.js +3 -5
  124. package/dist/core/session/startup.js.map +1 -1
  125. package/dist/core/spec/validator.d.ts.map +1 -1
  126. package/dist/core/spec/validator.js +2 -4
  127. package/dist/core/spec/validator.js.map +1 -1
  128. package/dist/core/validators/checkpoint.d.ts.map +1 -1
  129. package/dist/core/validators/checkpoint.js +3 -5
  130. package/dist/core/validators/checkpoint.js.map +1 -1
  131. package/dist/core/validators/passes-gate.d.ts +0 -4
  132. package/dist/core/validators/passes-gate.d.ts.map +1 -1
  133. package/dist/core/validators/passes-gate.js +5 -13
  134. package/dist/core/validators/passes-gate.js.map +1 -1
  135. package/dist/dashboard/data.d.ts +39 -0
  136. package/dist/dashboard/data.d.ts.map +1 -0
  137. package/dist/dashboard/data.js +89 -0
  138. package/dist/dashboard/data.js.map +1 -0
  139. package/dist/dashboard/index.d.ts +4 -0
  140. package/dist/dashboard/index.d.ts.map +1 -0
  141. package/dist/dashboard/index.js +20 -0
  142. package/dist/dashboard/index.js.map +1 -0
  143. package/dist/dashboard/stats.d.ts +20 -0
  144. package/dist/dashboard/stats.d.ts.map +1 -0
  145. package/dist/dashboard/stats.js +115 -0
  146. package/dist/dashboard/stats.js.map +1 -0
  147. package/dist/dashboard/types.d.ts +98 -0
  148. package/dist/dashboard/types.d.ts.map +1 -0
  149. package/dist/dashboard/types.js +8 -0
  150. package/dist/dashboard/types.js.map +1 -0
  151. package/dist/failure/recorder.d.ts +4 -0
  152. package/dist/failure/recorder.d.ts.map +1 -1
  153. package/dist/failure/recorder.js +9 -11
  154. package/dist/failure/recorder.js.map +1 -1
  155. package/dist/gates/acceptance.d.ts.map +1 -1
  156. package/dist/gates/acceptance.js +2 -4
  157. package/dist/gates/acceptance.js.map +1 -1
  158. package/dist/gates/contract.d.ts.map +1 -1
  159. package/dist/gates/contract.js +0 -3
  160. package/dist/gates/contract.js.map +1 -1
  161. package/dist/gates/performance.d.ts.map +1 -1
  162. package/dist/gates/performance.js +3 -5
  163. package/dist/gates/performance.js.map +1 -1
  164. package/dist/gates/review.d.ts.map +1 -1
  165. package/dist/gates/review.js +4 -6
  166. package/dist/gates/review.js.map +1 -1
  167. package/dist/gates/security.d.ts.map +1 -1
  168. package/dist/gates/security.js +2 -4
  169. package/dist/gates/security.js.map +1 -1
  170. package/dist/index.d.ts +9 -2
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +34 -3
  173. package/dist/index.js.map +1 -1
  174. package/dist/knowledge/import.d.ts +95 -0
  175. package/dist/knowledge/import.d.ts.map +1 -0
  176. package/dist/knowledge/import.js +429 -0
  177. package/dist/knowledge/import.js.map +1 -0
  178. package/dist/knowledge/index.d.ts +15 -0
  179. package/dist/knowledge/index.d.ts.map +1 -0
  180. package/dist/knowledge/index.js +40 -0
  181. package/dist/knowledge/index.js.map +1 -0
  182. package/dist/knowledge/ingest.d.ts +30 -0
  183. package/dist/knowledge/ingest.d.ts.map +1 -0
  184. package/dist/knowledge/ingest.js +94 -0
  185. package/dist/knowledge/ingest.js.map +1 -0
  186. package/dist/knowledge/lifecycle-hooks.d.ts +62 -0
  187. package/dist/knowledge/lifecycle-hooks.d.ts.map +1 -0
  188. package/dist/knowledge/lifecycle-hooks.js +140 -0
  189. package/dist/knowledge/lifecycle-hooks.js.map +1 -0
  190. package/dist/knowledge/lifecycle.d.ts +43 -0
  191. package/dist/knowledge/lifecycle.d.ts.map +1 -0
  192. package/dist/knowledge/lifecycle.js +141 -0
  193. package/dist/knowledge/lifecycle.js.map +1 -0
  194. package/dist/knowledge/lint.d.ts +57 -0
  195. package/dist/knowledge/lint.d.ts.map +1 -0
  196. package/dist/knowledge/lint.js +235 -0
  197. package/dist/knowledge/lint.js.map +1 -0
  198. package/dist/knowledge/query.d.ts +33 -0
  199. package/dist/knowledge/query.d.ts.map +1 -0
  200. package/dist/knowledge/query.js +107 -0
  201. package/dist/knowledge/query.js.map +1 -0
  202. package/dist/knowledge/reference-tracker.d.ts +31 -0
  203. package/dist/knowledge/reference-tracker.d.ts.map +1 -0
  204. package/dist/knowledge/reference-tracker.js +124 -0
  205. package/dist/knowledge/reference-tracker.js.map +1 -0
  206. package/dist/knowledge/store.d.ts +42 -0
  207. package/dist/knowledge/store.d.ts.map +1 -0
  208. package/dist/knowledge/store.js +278 -0
  209. package/dist/knowledge/store.js.map +1 -0
  210. package/dist/knowledge/types.d.ts +103 -0
  211. package/dist/knowledge/types.d.ts.map +1 -0
  212. package/dist/knowledge/types.js +17 -0
  213. package/dist/knowledge/types.js.map +1 -0
  214. package/dist/llm/adapter.d.ts +36 -0
  215. package/dist/llm/adapter.d.ts.map +1 -0
  216. package/dist/llm/adapter.js +118 -0
  217. package/dist/llm/adapter.js.map +1 -0
  218. package/dist/llm/index.d.ts +3 -0
  219. package/dist/llm/index.d.ts.map +1 -0
  220. package/dist/llm/index.js +19 -0
  221. package/dist/llm/index.js.map +1 -0
  222. package/dist/llm/types.d.ts +62 -0
  223. package/dist/llm/types.d.ts.map +1 -0
  224. package/dist/llm/types.js +8 -0
  225. package/dist/llm/types.js.map +1 -0
  226. package/dist/monitoring/context-tracker.d.ts +38 -0
  227. package/dist/monitoring/context-tracker.d.ts.map +1 -0
  228. package/dist/monitoring/context-tracker.js +162 -0
  229. package/dist/monitoring/context-tracker.js.map +1 -0
  230. package/dist/monitoring/index.d.ts +3 -0
  231. package/dist/monitoring/index.d.ts.map +1 -1
  232. package/dist/monitoring/index.js +6 -0
  233. package/dist/monitoring/index.js.map +1 -1
  234. package/dist/monitoring/knowledge-doctor.d.ts +78 -0
  235. package/dist/monitoring/knowledge-doctor.d.ts.map +1 -0
  236. package/dist/monitoring/knowledge-doctor.js +266 -0
  237. package/dist/monitoring/knowledge-doctor.js.map +1 -0
  238. package/dist/monitoring/knowledge-evolver.d.ts +72 -0
  239. package/dist/monitoring/knowledge-evolver.d.ts.map +1 -0
  240. package/dist/monitoring/knowledge-evolver.js +205 -0
  241. package/dist/monitoring/knowledge-evolver.js.map +1 -0
  242. package/dist/monitoring/performance-analyzer.d.ts.map +1 -1
  243. package/dist/monitoring/performance-analyzer.js +10 -4
  244. package/dist/monitoring/performance-analyzer.js.map +1 -1
  245. package/dist/monitoring/trace-analyzer.d.ts.map +1 -1
  246. package/dist/monitoring/trace-analyzer.js +12 -5
  247. package/dist/monitoring/trace-analyzer.js.map +1 -1
  248. package/dist/safety/index.d.ts +6 -0
  249. package/dist/safety/index.d.ts.map +1 -0
  250. package/dist/safety/index.js +22 -0
  251. package/dist/safety/index.js.map +1 -0
  252. package/dist/safety/input-guardrail.d.ts +36 -0
  253. package/dist/safety/input-guardrail.d.ts.map +1 -0
  254. package/dist/safety/input-guardrail.js +118 -0
  255. package/dist/safety/input-guardrail.js.map +1 -0
  256. package/dist/safety/output-guardrail.d.ts +40 -0
  257. package/dist/safety/output-guardrail.d.ts.map +1 -0
  258. package/dist/safety/output-guardrail.js +150 -0
  259. package/dist/safety/output-guardrail.js.map +1 -0
  260. package/dist/safety/sandbox.d.ts +45 -0
  261. package/dist/safety/sandbox.d.ts.map +1 -0
  262. package/dist/safety/sandbox.js +134 -0
  263. package/dist/safety/sandbox.js.map +1 -0
  264. package/dist/safety/tool-guardrail.d.ts +51 -0
  265. package/dist/safety/tool-guardrail.d.ts.map +1 -0
  266. package/dist/safety/tool-guardrail.js +147 -0
  267. package/dist/safety/tool-guardrail.js.map +1 -0
  268. package/dist/safety/types.d.ts +104 -0
  269. package/dist/safety/types.d.ts.map +1 -0
  270. package/dist/safety/types.js +6 -0
  271. package/dist/safety/types.js.map +1 -0
  272. package/dist/tools/core/index.d.ts +13 -0
  273. package/dist/tools/core/index.d.ts.map +1 -0
  274. package/dist/tools/core/index.js +198 -0
  275. package/dist/tools/core/index.js.map +1 -0
  276. package/dist/tools/index.d.ts +4 -0
  277. package/dist/tools/index.d.ts.map +1 -0
  278. package/dist/tools/index.js +20 -0
  279. package/dist/tools/index.js.map +1 -0
  280. package/dist/tools/registry.d.ts +59 -0
  281. package/dist/tools/registry.d.ts.map +1 -0
  282. package/dist/tools/registry.js +115 -0
  283. package/dist/tools/registry.js.map +1 -0
  284. package/dist/tools/types.d.ts +38 -0
  285. package/dist/tools/types.d.ts.map +1 -0
  286. package/dist/tools/types.js +6 -0
  287. package/dist/tools/types.js.map +1 -0
  288. package/dist/types/constraint.d.ts +4 -0
  289. package/dist/types/constraint.d.ts.map +1 -1
  290. package/dist/types/constraint.js.map +1 -1
  291. package/dist/utils/exec.d.ts +11 -1
  292. package/dist/utils/exec.d.ts.map +1 -1
  293. package/dist/utils/exec.js +19 -1
  294. package/dist/utils/exec.js.map +1 -1
  295. package/dist/verification/index.d.ts +4 -0
  296. package/dist/verification/index.d.ts.map +1 -0
  297. package/dist/verification/index.js +20 -0
  298. package/dist/verification/index.js.map +1 -0
  299. package/dist/verification/loop.d.ts +30 -0
  300. package/dist/verification/loop.d.ts.map +1 -0
  301. package/dist/verification/loop.js +114 -0
  302. package/dist/verification/loop.js.map +1 -0
  303. package/dist/verification/rules-based.d.ts +40 -0
  304. package/dist/verification/rules-based.d.ts.map +1 -0
  305. package/dist/verification/rules-based.js +130 -0
  306. package/dist/verification/rules-based.js.map +1 -0
  307. package/dist/verification/types.d.ts +69 -0
  308. package/dist/verification/types.d.ts.map +1 -0
  309. package/dist/verification/types.js +6 -0
  310. package/dist/verification/types.js.map +1 -0
  311. package/package.json +1 -1
  312. package/dist/cli/commands/diagnose.d.ts +0 -16
  313. package/dist/cli/commands/diagnose.d.ts.map +0 -1
  314. package/dist/cli/commands/diagnose.js +0 -195
  315. package/dist/cli/commands/diagnose.js.map +0 -1
  316. package/dist/cli/commands/propose.d.ts +0 -18
  317. package/dist/cli/commands/propose.d.ts.map +0 -1
  318. package/dist/cli/commands/propose.js +0 -331
  319. package/dist/cli/commands/propose.js.map +0 -1
  320. package/dist/cli/commands/traces.d.ts +0 -15
  321. package/dist/cli/commands/traces.d.ts.map +0 -1
  322. package/dist/cli/commands/traces.js +0 -167
  323. package/dist/cli/commands/traces.js.map +0 -1
  324. package/dist/extensions/long-running/constraints.d.ts +0 -38
  325. package/dist/extensions/long-running/constraints.d.ts.map +0 -1
  326. package/dist/extensions/long-running/constraints.js +0 -153
  327. package/dist/extensions/long-running/constraints.js.map +0 -1
  328. package/dist/extensions/long-running/index.d.ts +0 -30
  329. package/dist/extensions/long-running/index.d.ts.map +0 -1
  330. package/dist/extensions/long-running/index.js +0 -50
  331. package/dist/extensions/long-running/index.js.map +0 -1
  332. package/dist/extensions/long-running/types.d.ts +0 -154
  333. package/dist/extensions/long-running/types.d.ts.map +0 -1
  334. package/dist/extensions/long-running/types.js +0 -9
  335. package/dist/extensions/long-running/types.js.map +0 -1
  336. package/dist/presets/long-running.d.ts +0 -33
  337. package/dist/presets/long-running.d.ts.map +0 -1
  338. package/dist/presets/long-running.js +0 -52
  339. package/dist/presets/long-running.js.map +0 -1
package/README.md CHANGED
@@ -1,199 +1,171 @@
1
1
  # @dommaker/harness
2
2
 
3
- > AI Agent 的工程约束框架 — 让 Agent 不会乱承诺、不会跳过验证、不会简化测试。
3
+ > AI Agent 工程约束框架 — 从代码质量约束到知识积累引擎
4
4
 
5
- ---
6
-
7
- ## 🚀 快速开始
5
+ [![npm version](https://img.shields.io/npm/v/@dommaker/harness)](https://www.npmjs.com/package/@dommaker/harness)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
8
7
 
9
- ### 安装
8
+ ## 定位
10
9
 
11
- ```bash
12
- npm install -g @dommaker/harness
13
10
  ```
14
-
15
- ### 最小工作流
16
-
17
- ```bash
18
- # 开发前
19
- harness check
20
-
21
- # 开发 + 写测试
22
-
23
- # 提交前
24
- harness passes-gate
11
+ 代码质量约束(补偿模型弱点)
12
+ ↓
13
+ 知识积累基础设施(模型做不到的事)
14
+ + 最小安全护栏(模型无关的底线)
25
15
  ```
26
16
 
27
- ---
28
-
29
- ## 📋 CLI 命令
30
-
31
- ### 日常使用
32
-
33
- ```bash
34
- harness check # 检查铁律(开发前后必用)
35
- harness passes-gate # 测试门控(提交前验证)
36
- harness status # 查看状态(异常、统计)
37
- harness flow # 一键诊断 + 提案流程
38
- ```
17
+ **核心理念:Harness 不是目的,知识才是护城河。**
39
18
 
40
- ### 项目初始化
19
+ Skill、Agent、工具链会随模型迭代更新,但领域知识是永恒的。
41
20
 
42
- ```bash
43
- harness init --preset standard # 初始化配置
44
- harness init --print-snippets # 输出代码片段
45
- ```
21
+ ---
46
22
 
47
- ### 门禁检查
23
+ ## 安装
48
24
 
49
25
  ```bash
50
- # 测试门控
51
- harness passes-gate # 运行测试
52
- harness passes-gate --coverage # 检查覆盖率
53
- harness pg # 别名
54
-
55
- # 验收标准
56
- harness acceptance --task-id TASK-001 # 检查指定任务
57
- harness acceptance --check-all # 检查所有任务
58
- harness acceptance list # 列出验收标准
59
- harness acc # 别名
60
-
61
- # 性能门控
62
- harness performance --coverage --coverage-threshold 85 # 覆盖率检查
63
- harness performance --bundle --bundle-threshold 300 # 打包大小检查
64
- harness perf # 别名
65
-
66
- # 安全门控
67
- harness security # npm audit 检查
68
- harness security --severity critical # 只显示 critical 级别
69
- harness security audit # 详细漏洞报告
70
- harness sec # 别名
71
-
72
- # API 契约
73
- harness contract # OpenAPI Schema 验证
74
- harness contract validate # Schema 语法验证
75
- harness contract --contract-path api/openapi.yaml
76
-
77
- # 代码审查
78
- harness review # PR 审查状态检查
79
- harness review --min-reviewers 2 # 要求 2 个审批
80
- harness review status # PR 详情
26
+ npm install @dommaker/harness
81
27
  ```
82
28
 
83
- ### Spec 验证
29
+ ### CLI
84
30
 
85
31
  ```bash
86
- harness spec # 验证所有 Spec
87
- harness spec --staged # 验证暂存文件
88
- harness spec list # 支持的 Spec 类型
32
+ harness check # 检查约束(开发前后)
33
+ harness passes-gate # 测试门控(提交前)
34
+ harness status # 查看状态和异常
35
+ harness flow # 一键诊断 + 优化提案
36
+ harness init --preset standard # 初始化配置
89
37
  ```
90
38
 
91
- ### 检查点验证
39
+ ### 作为库使用
92
40
 
93
- ```bash
94
- harness validate # 验证检查点
95
- harness validate --strict # 严格模式
96
- harness validate -f checkpoint.json # 指定文件
97
- ```
41
+ ```typescript
42
+ import {
43
+ // 约束系统
44
+ checkConstraints,
45
+ checkBeforeExecution,
46
+ interceptOperation,
47
+ // 知识引擎
48
+ KnowledgeService,
49
+ // 安全护栏
50
+ SafetyService,
51
+ // 上下文管理
52
+ ContextService,
53
+ // Agent 生命周期
54
+ AgentService,
55
+ } from '@dommaker/harness';
98
56
 
99
- ### 报告
57
+ // 约束检查
58
+ const result = await checkConstraints(context);
59
+ if (!result.passed) {
60
+ console.error(result.ironLaws.filter(r => !r.passed));
61
+ }
100
62
 
101
- ```bash
102
- harness report # 生成 Markdown 报告
103
- harness report -f json # JSON 格式
104
- harness report -o report.md # 输出到文件
105
- ```
63
+ // 知识查询
64
+ const knowledge = KnowledgeService.getInstance();
65
+ const docs = await knowledge.getQuery().search('architecture decisions');
106
66
 
107
- ### 诊断
67
+ // 安全护栏
68
+ const safety = SafetyService.getInstance();
69
+ const guardrail = safety.getInputGuardrail();
70
+ await guardrail.check(userInput);
108
71
 
109
- ```bash
110
- harness flow # 一键诊断 + 提案
111
- harness flow --auto-apply # 自动应用低风险提案
72
+ // Token 预算
73
+ const ctx = ContextService.getInstance();
74
+ const budget = ctx.getBudget();
75
+ budget.allocate('system', 2000);
76
+ budget.allocate('user', 4000);
112
77
  ```
113
78
 
114
79
  ---
115
80
 
116
- ## 🎯 核心概念
81
+ ## 核心架构
117
82
 
118
83
  ### 三层约束体系
119
84
 
120
85
  | 层级 | 严重性 | 说明 |
121
86
  |------|:------:|------|
122
- | **Iron Law** | 🔴 error | 绝对禁止,无例外 |
123
- | **Guideline** | 🟡 warning | 推荐遵守,有例外 |
124
- | **Tip** | 🔵 info | 信息性提示 |
125
-
126
- ### 7 条铁律
127
-
128
- | ID | 规则 |
129
- |---|------|
130
- | `no_bypass_checkpoint` | 禁止跳过检查点 |
131
- | `no_self_approval` | 禁止自评通过(必须测试)|
132
- | `no_completion_without_verification` | 完成必须验证 |
133
- | `no_test_simplification` | 禁止简化测试 |
134
- | `incremental_progress` | 单任务单会话 |
135
- | `verify_external_capability` | 外部能力先验证 |
136
- | `no_implementation_without_requirement_review` | 实现后对比需求 |
137
-
138
- ### 7 种门禁(均有 CLI 命令)
139
-
140
- | 门禁 | CLI 命令 | 用途 |
141
- |------|:--------:|------|
142
- | PassesGate | `passes-gate` / `pg` | 测试门控 |
143
- | SpecAcceptanceGate | `acceptance` / `acc` | 验收标准检查 |
144
- | PerformanceGate | `performance` / `perf` | 性能门控 |
145
- | SecurityGate | `security` / `sec` | 安全检查 |
146
- | ContractGate | `contract` | API 契约验证 |
147
- | ReviewGate | `review` | PR 审核检查 |
148
- | CheckpointValidator | `validate` | 检查点验证 |
149
- | CheckpointValidator | 检查点验证 |
150
- | SpecAcceptanceGate | 验收标准检查 |
87
+ | **Iron Law** | error | 绝对禁止,无例外(7 条) |
88
+ | **Guideline** | warning | 推荐遵守,有例外(9 条) |
89
+ | **Tip** | info | 信息性提示(2 条) |
90
+
91
+ ### 子系统
92
+
93
+ | 模块 | 目录 | 说明 |
94
+ |------|------|------|
95
+ | **约束引擎** | `core/`, `constraints/` | 三层约束检查、拦截器、自定义约束配置 |
96
+ | **知识引擎** | `knowledge/` | 存储、查询、引用追踪、质量检查、生命周期(draft→canonical→archived) |
97
+ | **上下文管理** | `context/` | Token 预算、会话压缩、渐进式加载、知识注入 |
98
+ | **安全护栏** | `safety/` | 输入/输出/工具调用安全检查、沙箱(L1-L4) |
99
+ | **验证循环** | `verification/` | 规则引擎 + 推理验证,支持检查点恢复 |
100
+ | **门禁系统** | `gates/` | 8 种门禁:测试/验收/性能/安全/契约/审查/命令/检查点 |
101
+ | **监控** | `monitoring/` | Trace 收集分析、约束诊断/进化、知识诊断/进化 |
102
+ | **Agent 管理** | `agents/` | Agent 生命周期状态机(init→running→completed) |
103
+ | **LLM 集成** | `llm/` | LLM 适配层,支持多 provider |
104
+ | **失败处理** | `failure/` | 错误分类、失败记录 |
105
+ | **Dashboard** | `dashboard/` | 统计面板、状态展示 |
106
+ | **架构约束** | `architecture/` | 架构级约束检查、跨项目依赖检查 |
107
+ | **Spec 检查** | `spec/` | 代码注解中的 Spec 验证 |
151
108
 
152
109
  ---
153
110
 
154
- ## 🔧 代码集成
111
+ ## CLI 命令
155
112
 
156
- ```typescript
157
- import {
158
- IronLawChecker,
159
- PassesGate,
160
- CheckpointValidator,
161
- interceptOperation,
162
- } from '@dommaker/harness';
113
+ ### 日常
163
114
 
164
- // 铁律检查
165
- const checker = IronLawChecker.getInstance();
166
- const results = await checker.checkAll(context);
115
+ ```bash
116
+ harness check # 约束检查
117
+ harness passes-gate [options] # 测试门控(别名: pg)
118
+ harness status [--anomalies] # 状态查看
119
+ harness flow [--auto-apply] # 诊断 + 提案
120
+ ```
167
121
 
168
- // 测试门控
169
- const gate = new PassesGate({ requireEvidence: true });
170
- const passed = await gate.runTests();
122
+ ### 门禁
171
123
 
172
- // 检查点验证
173
- const validator = CheckpointValidator.getInstance();
174
- const result = await validator.validate(checkpoints, context);
124
+ ```bash
125
+ harness acceptance [--task-id ID] [--check-all] # 验收标准(别名: acc)
126
+ harness performance [--coverage] [--bundle] # 性能门控(别名: perf)
127
+ harness security [--severity level] # 安全检查(别名: sec)
128
+ harness contract [--contract-path path] # API 契约验证
129
+ harness review [--min-reviewers N] # PR 审查检查
130
+ harness command "command string" # 命令黑名单(别名: cmd)
131
+ ```
175
132
 
176
- // 拦截器(自动执行 enforcement)
177
- await interceptOperation('task_completion_claim', context);
133
+ ### 其他
134
+
135
+ ```bash
136
+ harness init [--preset standard|strict|relaxed] # 初始化
137
+ harness validate [--strict] # 检查点验证
138
+ harness spec [--staged] # Spec 验证
139
+ harness report [-f json|markdown] [-o file] # 报告生成
178
140
  ```
179
141
 
180
142
  ---
181
143
 
182
- ## 📁 项目配置
144
+ ## 配置
183
145
 
184
146
  ### .harness/config.yml
185
147
 
186
148
  ```yaml
187
- preset: standard
149
+ preset: standard # standard | strict | relaxed
188
150
 
189
151
  # 自定义约束例外
190
152
  custom_constraints:
191
153
  no_fix_without_root_cause:
192
154
  extend_exceptions:
193
- - my_special_case
155
+ - hotfix_branch
194
156
  ```
195
157
 
196
- ### CI 集成
158
+ ### Presets
159
+
160
+ | Preset | 说明 |
161
+ |--------|------|
162
+ | `strict` | 全部约束启用(Iron Laws + Guidelines + Tips) |
163
+ | `standard` | Iron Laws + Guidelines(默认) |
164
+ | `relaxed` | 仅 Iron Laws |
165
+
166
+ ---
167
+
168
+ ## CI 集成
197
169
 
198
170
  ```yaml
199
171
  # .github/workflows/harness-check.yml
@@ -209,63 +181,34 @@ jobs:
209
181
 
210
182
  ---
211
183
 
212
- ## 📊 Trace & 日志
184
+ ## 日志与诊断
213
185
 
214
- ### 目录结构
186
+ 运行时状态存储在 `.harness/` 目录:
215
187
 
216
188
  ```
217
189
  .harness/
218
- ├── traces/
219
- │ ├── execution.log # 约束检查记录(JSON Lines)
220
- │ └── summary.json # 统计汇总
221
- └── state.json # Harness 状态
190
+ ├── traces/ # 约束检查记录(JSON Lines)
191
+ ├── failures/ # 失败记录
192
+ └── state.json # 运行状态
222
193
  ```
223
194
 
224
- ### 查看日志
225
-
226
195
  ```bash
227
- # 查看状态和统计
228
- harness status
229
-
230
- # 查看详细统计
231
- harness status --detail
232
-
233
- # 只看异常
234
- harness status --anomalies
235
-
236
- # 分析最近 N 小时
237
- harness status --hours 48
238
- ```
239
-
240
- ### 日志格式
241
-
242
- **execution.log**(JSON Lines 格式):
243
- ```json
244
- {"timestamp":"2026-04-28T15:00:00Z","constraintId":"no_bypass_checkpoint","result":"passed","duration":12}
245
- {"timestamp":"2026-04-28T15:01:00Z","constraintId":"no_self_approval","result":"bypassed","reason":"hotfix"}
196
+ harness status --anomalies # 查看异常
197
+ harness status --hours 48 # 最近 48 小时统计
198
+ harness flow --auto-apply # 诊断 + 自动应用低风险提案
246
199
  ```
247
200
 
248
- **summary.json**:
249
- ```json
250
- {"totalChecks":150,"passRate":0.92,"bypassRate":0.08,"anomalies":2}
251
- ```
252
-
253
- ### 异常检测
254
-
255
- 当 `harness status --anomalies` 发现异常时,运行 `harness flow` 进行诊断和优化提案。
256
-
257
201
  ---
258
202
 
259
- ## 🔧 开发
203
+ ## 开发
260
204
 
261
205
  ```bash
262
206
  npm install
263
- npm run build
264
- npm test
207
+ npm run build # 编译 TypeScript
208
+ npm test # 运行测试(覆盖率阈值 50%)
209
+ npm run lint # ESLint
265
210
  ```
266
211
 
267
- ---
268
-
269
- ## 📝 License
212
+ ## 许可证
270
213
 
271
- MIT © dommaker
214
+ MIT
package/bin/harness.js CHANGED
@@ -7,13 +7,14 @@
7
7
  */
8
8
 
9
9
  const { Command } = require('commander');
10
- const {
11
- check,
12
- listLaws,
13
- validate,
14
- runPassesGate,
10
+ const { version } = require('../package.json');
11
+ const {
12
+ check,
13
+ listLaws,
14
+ validate,
15
+ runPassesGate,
15
16
  checkCoverage,
16
- init,
17
+ init,
17
18
  report,
18
19
  status,
19
20
  flow,
@@ -27,7 +28,8 @@ const {
27
28
  contract,
28
29
  validateSchema,
29
30
  review,
30
- reviewStatus
31
+ reviewStatus,
32
+ executeCommand,
31
33
  } = require('../dist/cli/commands/index');
32
34
 
33
35
  const program = new Command();
@@ -35,7 +37,7 @@ const program = new Command();
35
37
  program
36
38
  .name('harness')
37
39
  .description('通用工程约束框架 - 铁律系统、检查点验证、测试门控、执行追踪')
38
- .version('0.8.0');
40
+ .version(version);
39
41
 
40
42
  // ========================================
41
43
  // harness check
@@ -116,7 +118,7 @@ program
116
118
  .command('report')
117
119
  .description('生成检查报告')
118
120
  .option('-o, --output <path>', '输出文件路径')
119
- .option('-f, --format <format>', '输出格式 (json/markdown)', 'markdown')
121
+ .option('-f, --format <format>', '输出格式 (json/markdown/html)', 'markdown')
120
122
  .option('-p, --project-path <path>', '项目路径')
121
123
  .action(async (options) => {
122
124
  await report(options);
@@ -260,7 +262,7 @@ program
260
262
  .description('API 契约门控,检查 OpenAPI Schema')
261
263
  .option('-p, --project-path <path>', '项目路径')
262
264
  .option('--contract-path <path>', '契约文件路径', 'openapi.yaml')
263
- .option('--strict', '严格模式', true)
265
+ .option('--no-strict', '关闭严格模式')
264
266
  .option('--allow-breaking', '允许破坏性变更', false)
265
267
  .action(async (subcommand, options, command) => {
266
268
  if (subcommand === 'validate') {
@@ -278,8 +280,8 @@ program
278
280
  .description('代码审查门控,检查审查状态')
279
281
  .option('-p, --project-path <path>', '项目路径')
280
282
  .option('--min-reviewers <n>', '最少审查人数', '1')
281
- .option('--require-approval', '要求审批', true)
282
- .option('--block-on-changes', '阻止变更请求', true)
283
+ .option('--no-require-approval', '不要求审批')
284
+ .option('--no-block-on-changes', '不阻止变更请求')
283
285
  .option('--allowed-reviewers <list>', '允许的审查者(逗号分隔)')
284
286
  .action(async (subcommand, options, command) => {
285
287
  if (subcommand === 'status') {
@@ -295,5 +297,20 @@ program
295
297
  }
296
298
  });
297
299
 
300
+ // ========================================
301
+ // harness command
302
+ // ========================================
303
+ program
304
+ .command('command [cmd]')
305
+ .description('检查命令是否在黑名单中')
306
+ .alias('cmd')
307
+ .option('-l, --level', '显示风险等级')
308
+ .option('--list', '列出所有黑名单规则')
309
+ .option('--json', 'JSON 格式输出')
310
+ .option('--strict', '严格模式(warn 也阻止)')
311
+ .action(async (cmd, options) => {
312
+ await executeCommand(cmd, options);
313
+ });
314
+
298
315
  // 解析命令行参数
299
316
  program.parse();
@@ -0,0 +1,3 @@
1
+ export * from './types';
2
+ export * from './lifecycle';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./types"), exports);
18
+ __exportStar(require("./lifecycle"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/agents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,8CAA4B"}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Agent 生命周期管理
3
+ *
4
+ * 管理 Agent 的启动、监控、回退、终止
5
+ */
6
+ import type { AgentConfig, AgentState, AgentStatus, AgentEvent, FallbackStrategy } from './types';
7
+ export type EventHandler = (event: AgentEvent) => void;
8
+ export declare class AgentLifecycle {
9
+ private agents;
10
+ private configs;
11
+ private strategies;
12
+ private eventHandlers;
13
+ constructor();
14
+ /**
15
+ * 注册 Agent
16
+ */
17
+ register(config: AgentConfig): AgentState;
18
+ /**
19
+ * 启动 Agent
20
+ */
21
+ start(id: string): AgentState | undefined;
22
+ /**
23
+ * 完成 Agent
24
+ */
25
+ complete(id: string, metadata?: Record<string, unknown>): AgentState | undefined;
26
+ /**
27
+ * 标记失败
28
+ */
29
+ fail(id: string, error: string): AgentState | undefined;
30
+ /**
31
+ * 终止 Agent
32
+ */
33
+ terminate(id: string): AgentState | undefined;
34
+ /**
35
+ * 获取 Agent 状态
36
+ */
37
+ getState(id: string): AgentState | undefined;
38
+ /**
39
+ * 获取所有 Agent 状态
40
+ */
41
+ getAllStates(): AgentState[];
42
+ /**
43
+ * 按状态过滤
44
+ */
45
+ getByStatus(status: AgentStatus): AgentState[];
46
+ /**
47
+ * 注册回退策略
48
+ */
49
+ addFallbackStrategy(strategy: FallbackStrategy): void;
50
+ /**
51
+ * 注册事件处理器
52
+ */
53
+ onEvent(handler: EventHandler): void;
54
+ /**
55
+ * 应用回退策略
56
+ */
57
+ private applyFallbackStrategies;
58
+ private emit;
59
+ /**
60
+ * 移除 Agent
61
+ */
62
+ remove(id: string): boolean;
63
+ /**
64
+ * 清空所有 Agent
65
+ */
66
+ clear(): void;
67
+ }
68
+ //# sourceMappingURL=lifecycle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lifecycle.d.ts","sourceRoot":"","sources":["../../src/agents/lifecycle.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAEjB,MAAM,MAAM,YAAY,GAAG,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;AAEvD,qBAAa,cAAc;IACzB,OAAO,CAAC,MAAM,CAA0B;IACxC,OAAO,CAAC,OAAO,CAA2B;IAC1C,OAAO,CAAC,UAAU,CAAqB;IACvC,OAAO,CAAC,aAAa,CAAiB;;IAStC;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU;IAYzC;;OAEG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAUzC;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,UAAU,GAAG,SAAS;IAWhF;;OAEG;IACH,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAavD;;OAEG;IACH,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAU7C;;OAEG;IACH,QAAQ,CAAC,EAAE,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI5C;;OAEG;IACH,YAAY,IAAI,UAAU,EAAE;IAI5B;;OAEG;IACH,WAAW,CAAC,MAAM,EAAE,WAAW,GAAG,UAAU,EAAE;IAI9C;;OAEG;IACH,mBAAmB,CAAC,QAAQ,EAAE,gBAAgB,GAAG,IAAI;IAIrD;;OAEG;IACH,OAAO,CAAC,OAAO,EAAE,YAAY,GAAG,IAAI;IAIpC;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAqC/B,OAAO,CAAC,IAAI;IAUZ;;OAEG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO;IAK3B;;OAEG;IACH,KAAK,IAAI,IAAI;CAId"}