@webpieces/ai-hook-rules 0.4.838 → 0.4.840

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 (390) hide show
  1. package/README.md +12 -140
  2. package/package.json +7 -15
  3. package/src/adapters/hook-app-fixtures.d.ts +1 -1
  4. package/src/adapters/hook-app-fixtures.js +0 -8
  5. package/src/adapters/hook-app-fixtures.js.map +1 -1
  6. package/src/adapters/hook-core.d.ts +1 -21
  7. package/src/adapters/hook-core.js +22 -341
  8. package/src/adapters/hook-core.js.map +1 -1
  9. package/src/core/load-rules.d.ts +4 -39
  10. package/src/core/load-rules.js +15 -127
  11. package/src/core/load-rules.js.map +1 -1
  12. package/src/core/rules/catch-error-pattern.d.ts +3 -3
  13. package/src/core/rules/catch-error-pattern.js +13 -13
  14. package/src/core/rules/catch-error-pattern.js.map +1 -1
  15. package/src/core/rules/index.d.ts +1 -14
  16. package/src/core/rules/index.js +1 -17
  17. package/src/core/rules/index.js.map +1 -1
  18. package/src/core/rules/match-rule.d.ts +3 -3
  19. package/src/core/rules/match-rule.js +6 -6
  20. package/src/core/rules/match-rule.js.map +1 -1
  21. package/src/core/rules/max-file-lines.d.ts +3 -3
  22. package/src/core/rules/max-file-lines.js +7 -7
  23. package/src/core/rules/max-file-lines.js.map +1 -1
  24. package/src/core/rules/no-any-unknown.d.ts +3 -3
  25. package/src/core/rules/no-any-unknown.js +6 -6
  26. package/src/core/rules/no-any-unknown.js.map +1 -1
  27. package/src/core/rules/no-custom-css.d.ts +3 -3
  28. package/src/core/rules/no-custom-css.js +7 -7
  29. package/src/core/rules/no-custom-css.js.map +1 -1
  30. package/src/core/rules/no-destructure.d.ts +3 -3
  31. package/src/core/rules/no-destructure.js +7 -7
  32. package/src/core/rules/no-destructure.js.map +1 -1
  33. package/src/core/rules/no-implicit-any.d.ts +3 -3
  34. package/src/core/rules/no-implicit-any.js +6 -6
  35. package/src/core/rules/no-implicit-any.js.map +1 -1
  36. package/src/core/rules/no-js-files.d.ts +3 -3
  37. package/src/core/rules/no-js-files.js +6 -6
  38. package/src/core/rules/no-js-files.js.map +1 -1
  39. package/src/core/rules/no-process-exit-outside-main.d.ts +3 -3
  40. package/src/core/rules/no-process-exit-outside-main.js +7 -7
  41. package/src/core/rules/no-process-exit-outside-main.js.map +1 -1
  42. package/src/core/rules/no-symbol-di-tokens.d.ts +3 -3
  43. package/src/core/rules/no-symbol-di-tokens.js +7 -7
  44. package/src/core/rules/no-symbol-di-tokens.js.map +1 -1
  45. package/src/core/rules/no-unmanaged-exceptions.d.ts +3 -3
  46. package/src/core/rules/no-unmanaged-exceptions.js +9 -9
  47. package/src/core/rules/no-unmanaged-exceptions.js.map +1 -1
  48. package/src/core/rules/require-return-type.d.ts +3 -3
  49. package/src/core/rules/require-return-type.js +6 -6
  50. package/src/core/rules/require-return-type.js.map +1 -1
  51. package/src/core/rules/throw-cause-required.d.ts +3 -3
  52. package/src/core/rules/throw-cause-required.js +9 -9
  53. package/src/core/rules/throw-cause-required.js.map +1 -1
  54. package/src/core/rules/validate-ts-in-src.d.ts +3 -3
  55. package/src/core/rules/validate-ts-in-src.js +7 -7
  56. package/src/core/rules/validate-ts-in-src.js.map +1 -1
  57. package/src/core/runner.d.ts +10 -19
  58. package/src/core/runner.js +24 -622
  59. package/src/core/runner.js.map +1 -1
  60. package/src/index.d.ts +2 -15
  61. package/src/index.js +4 -54
  62. package/src/index.js.map +1 -1
  63. package/openclaw.plugin.json +0 -15
  64. package/src/adapters/agent-adapters.d.ts +0 -13
  65. package/src/adapters/agent-adapters.js +0 -23
  66. package/src/adapters/agent-adapters.js.map +0 -1
  67. package/src/adapters/agent-payload.d.ts +0 -48
  68. package/src/adapters/agent-payload.js +0 -30
  69. package/src/adapters/agent-payload.js.map +0 -1
  70. package/src/adapters/agent-response.d.ts +0 -5
  71. package/src/adapters/agent-response.js +0 -86
  72. package/src/adapters/agent-response.js.map +0 -1
  73. package/src/adapters/claude-code-adapter.d.ts +0 -26
  74. package/src/adapters/claude-code-adapter.js +0 -69
  75. package/src/adapters/claude-code-adapter.js.map +0 -1
  76. package/src/adapters/codex-adapter.d.ts +0 -19
  77. package/src/adapters/codex-adapter.js +0 -48
  78. package/src/adapters/codex-adapter.js.map +0 -1
  79. package/src/adapters/codex-subagent-guard.d.ts +0 -45
  80. package/src/adapters/codex-subagent-guard.js +0 -88
  81. package/src/adapters/codex-subagent-guard.js.map +0 -1
  82. package/src/adapters/detect-ai.d.ts +0 -70
  83. package/src/adapters/detect-ai.js +0 -82
  84. package/src/adapters/detect-ai.js.map +0 -1
  85. package/src/adapters/guards-hook.d.ts +0 -3
  86. package/src/adapters/guards-hook.js +0 -30
  87. package/src/adapters/guards-hook.js.map +0 -1
  88. package/src/adapters/openclaw-plugin.d.ts +0 -14
  89. package/src/adapters/openclaw-plugin.js +0 -87
  90. package/src/adapters/openclaw-plugin.js.map +0 -1
  91. package/src/adapters/review-identity-stamper.d.ts +0 -20
  92. package/src/adapters/review-identity-stamper.js +0 -34
  93. package/src/adapters/review-identity-stamper.js.map +0 -1
  94. package/src/bin/codex-trust.d.ts +0 -105
  95. package/src/bin/codex-trust.js +0 -205
  96. package/src/bin/codex-trust.js.map +0 -1
  97. package/src/bin/dev-hook-install.d.ts +0 -1
  98. package/src/bin/dev-hook-install.js +0 -82
  99. package/src/bin/dev-hook-install.js.map +0 -1
  100. package/src/bin/dev-hook-uninstall.d.ts +0 -1
  101. package/src/bin/dev-hook-uninstall.js +0 -45
  102. package/src/bin/dev-hook-uninstall.js.map +0 -1
  103. package/src/bin/hook-registration.d.ts +0 -429
  104. package/src/bin/hook-registration.js +0 -661
  105. package/src/bin/hook-registration.js.map +0 -1
  106. package/src/bin/install-entry.d.ts +0 -19
  107. package/src/bin/install-entry.js +0 -128
  108. package/src/bin/install-entry.js.map +0 -1
  109. package/src/bin/l0-allowlist.d.ts +0 -49
  110. package/src/bin/l0-allowlist.js +0 -528
  111. package/src/bin/l0-allowlist.js.map +0 -1
  112. package/src/bin/l0-codex-read.d.ts +0 -21
  113. package/src/bin/l0-codex-read.js +0 -109
  114. package/src/bin/l0-codex-read.js.map +0 -1
  115. package/src/bin/l0-decide.d.ts +0 -50
  116. package/src/bin/l0-decide.js +0 -103
  117. package/src/bin/l0-decide.js.map +0 -1
  118. package/src/bin/l0-entry.d.ts +0 -103
  119. package/src/bin/l0-entry.js +0 -98
  120. package/src/bin/l0-entry.js.map +0 -1
  121. package/src/bin/l0-ignored-tools.d.ts +0 -38
  122. package/src/bin/l0-ignored-tools.js +0 -44
  123. package/src/bin/l0-ignored-tools.js.map +0 -1
  124. package/src/bin/managed-env.d.ts +0 -46
  125. package/src/bin/managed-env.js +0 -50
  126. package/src/bin/managed-env.js.map +0 -1
  127. package/src/bin/neighbour-hooks.d.ts +0 -42
  128. package/src/bin/neighbour-hooks.js +0 -177
  129. package/src/bin/neighbour-hooks.js.map +0 -1
  130. package/src/bin/reviewer-agent.d.ts +0 -19
  131. package/src/bin/reviewer-agent.js +0 -135
  132. package/src/bin/reviewer-agent.js.map +0 -1
  133. package/src/bin/settings-shape.d.ts +0 -37
  134. package/src/bin/settings-shape.js +0 -17
  135. package/src/bin/settings-shape.js.map +0 -1
  136. package/src/bin/setup-config.d.ts +0 -19
  137. package/src/bin/setup-config.js +0 -370
  138. package/src/bin/setup-config.js.map +0 -1
  139. package/src/bin/setup.d.ts +0 -78
  140. package/src/bin/setup.js +0 -400
  141. package/src/bin/setup.js.map +0 -1
  142. package/src/bin/shim-audit-log.d.ts +0 -119
  143. package/src/bin/shim-audit-log.js +0 -286
  144. package/src/bin/shim-audit-log.js.map +0 -1
  145. package/src/bin/shim-deny-reason.d.ts +0 -1
  146. package/src/bin/shim-deny-reason.js +0 -244
  147. package/src/bin/shim-deny-reason.js.map +0 -1
  148. package/src/bin/shim-drift-fix.d.ts +0 -1
  149. package/src/bin/shim-drift-fix.js +0 -72
  150. package/src/bin/shim-drift-fix.js.map +0 -1
  151. package/src/bin/shim-testkit.d.ts +0 -107
  152. package/src/bin/shim-testkit.js +0 -197
  153. package/src/bin/shim-testkit.js.map +0 -1
  154. package/src/bin/shim-version-drift.d.ts +0 -1
  155. package/src/bin/shim-version-drift.js +0 -164
  156. package/src/bin/shim-version-drift.js.map +0 -1
  157. package/src/bin/shim.d.ts +0 -16
  158. package/src/bin/shim.js +0 -636
  159. package/src/bin/shim.js.map +0 -1
  160. package/src/bin/upgrade-shim.d.ts +0 -18
  161. package/src/bin/upgrade-shim.js +0 -283
  162. package/src/bin/upgrade-shim.js.map +0 -1
  163. package/src/core/ai-type-context.d.ts +0 -36
  164. package/src/core/ai-type-context.js +0 -45
  165. package/src/core/ai-type-context.js.map +0 -1
  166. package/src/core/apply-patch-parse.d.ts +0 -36
  167. package/src/core/apply-patch-parse.js +0 -154
  168. package/src/core/apply-patch-parse.js.map +0 -1
  169. package/src/core/build-context.d.ts +0 -10
  170. package/src/core/build-context.js +0 -66
  171. package/src/core/build-context.js.map +0 -1
  172. package/src/core/command-scan.d.ts +0 -122
  173. package/src/core/command-scan.js +0 -282
  174. package/src/core/command-scan.js.map +0 -1
  175. package/src/core/custom-rule-adapter.d.ts +0 -22
  176. package/src/core/custom-rule-adapter.js +0 -50
  177. package/src/core/custom-rule-adapter.js.map +0 -1
  178. package/src/core/decision-log.d.ts +0 -190
  179. package/src/core/decision-log.js +0 -406
  180. package/src/core/decision-log.js.map +0 -1
  181. package/src/core/delete-scoped-rules.d.ts +0 -8
  182. package/src/core/delete-scoped-rules.js +0 -31
  183. package/src/core/delete-scoped-rules.js.map +0 -1
  184. package/src/core/disable-directives.d.ts +0 -8
  185. package/src/core/disable-directives.js +0 -80
  186. package/src/core/disable-directives.js.map +0 -1
  187. package/src/core/effective-tree.d.ts +0 -204
  188. package/src/core/effective-tree.js +0 -277
  189. package/src/core/effective-tree.js.map +0 -1
  190. package/src/core/excluded-path-escape.d.ts +0 -101
  191. package/src/core/excluded-path-escape.js +0 -236
  192. package/src/core/excluded-path-escape.js.map +0 -1
  193. package/src/core/excluded-paths.d.ts +0 -23
  194. package/src/core/excluded-paths.js +0 -54
  195. package/src/core/excluded-paths.js.map +0 -1
  196. package/src/core/fix-hint.d.ts +0 -40
  197. package/src/core/fix-hint.js +0 -53
  198. package/src/core/fix-hint.js.map +0 -1
  199. package/src/core/force-to-root.d.ts +0 -32
  200. package/src/core/force-to-root.js +0 -60
  201. package/src/core/force-to-root.js.map +0 -1
  202. package/src/core/guard-index-doc.d.ts +0 -63
  203. package/src/core/guard-index-doc.js +0 -172
  204. package/src/core/guard-index-doc.js.map +0 -1
  205. package/src/core/instruct-ai-writer.d.ts +0 -1
  206. package/src/core/instruct-ai-writer.js +0 -6
  207. package/src/core/instruct-ai-writer.js.map +0 -1
  208. package/src/core/l0-fault-codes.d.ts +0 -85
  209. package/src/core/l0-fault-codes.js +0 -121
  210. package/src/core/l0-fault-codes.js.map +0 -1
  211. package/src/core/l0-matrix.d.ts +0 -114
  212. package/src/core/l0-matrix.js +0 -416
  213. package/src/core/l0-matrix.js.map +0 -1
  214. package/src/core/l0-tooling-doc.d.ts +0 -45
  215. package/src/core/l0-tooling-doc.js +0 -258
  216. package/src/core/l0-tooling-doc.js.map +0 -1
  217. package/src/core/l1-doc.d.ts +0 -7
  218. package/src/core/l1-doc.js +0 -340
  219. package/src/core/l1-doc.js.map +0 -1
  220. package/src/core/l1-matrix-doc.d.ts +0 -31
  221. package/src/core/l1-matrix-doc.js +0 -111
  222. package/src/core/l1-matrix-doc.js.map +0 -1
  223. package/src/core/l1-rows.d.ts +0 -167
  224. package/src/core/l1-rows.js +0 -262
  225. package/src/core/l1-rows.js.map +0 -1
  226. package/src/core/l2-doc.d.ts +0 -7
  227. package/src/core/l2-doc.js +0 -385
  228. package/src/core/l2-doc.js.map +0 -1
  229. package/src/core/l2-matrix-doc.d.ts +0 -23
  230. package/src/core/l2-matrix-doc.js +0 -72
  231. package/src/core/l2-matrix-doc.js.map +0 -1
  232. package/src/core/l2-row.d.ts +0 -54
  233. package/src/core/l2-row.js +0 -75
  234. package/src/core/l2-row.js.map +0 -1
  235. package/src/core/l2-rows.d.ts +0 -56
  236. package/src/core/l2-rows.js +0 -272
  237. package/src/core/l2-rows.js.map +0 -1
  238. package/src/core/load-config.d.ts +0 -1
  239. package/src/core/load-config.js +0 -9
  240. package/src/core/load-config.js.map +0 -1
  241. package/src/core/log-stream.d.ts +0 -117
  242. package/src/core/log-stream.js +0 -156
  243. package/src/core/log-stream.js.map +0 -1
  244. package/src/core/log-streams.d.ts +0 -48
  245. package/src/core/log-streams.js +0 -55
  246. package/src/core/log-streams.js.map +0 -1
  247. package/src/core/log-target.d.ts +0 -21
  248. package/src/core/log-target.js +0 -29
  249. package/src/core/log-target.js.map +0 -1
  250. package/src/core/main-sync-log.d.ts +0 -16
  251. package/src/core/main-sync-log.js +0 -105
  252. package/src/core/main-sync-log.js.map +0 -1
  253. package/src/core/main-sync-refresh.d.ts +0 -39
  254. package/src/core/main-sync-refresh.js +0 -96
  255. package/src/core/main-sync-refresh.js.map +0 -1
  256. package/src/core/main-sync-timeout.d.ts +0 -32
  257. package/src/core/main-sync-timeout.js +0 -94
  258. package/src/core/main-sync-timeout.js.map +0 -1
  259. package/src/core/matrix-cures.d.ts +0 -12
  260. package/src/core/matrix-cures.js +0 -56
  261. package/src/core/matrix-cures.js.map +0 -1
  262. package/src/core/missing-directory.d.ts +0 -38
  263. package/src/core/missing-directory.js +0 -66
  264. package/src/core/missing-directory.js.map +0 -1
  265. package/src/core/read-only-inspection.d.ts +0 -34
  266. package/src/core/read-only-inspection.js +0 -88
  267. package/src/core/read-only-inspection.js.map +0 -1
  268. package/src/core/rejection-log.d.ts +0 -9
  269. package/src/core/rejection-log.js +0 -258
  270. package/src/core/rejection-log.js.map +0 -1
  271. package/src/core/report.d.ts +0 -21
  272. package/src/core/report.js +0 -73
  273. package/src/core/report.js.map +0 -1
  274. package/src/core/rule-base.d.ts +0 -39
  275. package/src/core/rule-base.js +0 -36
  276. package/src/core/rule-base.js.map +0 -1
  277. package/src/core/rules/branch-creation-guard.d.ts +0 -113
  278. package/src/core/rules/branch-creation-guard.js +0 -422
  279. package/src/core/rules/branch-creation-guard.js.map +0 -1
  280. package/src/core/rules/branch-switch-scan.d.ts +0 -43
  281. package/src/core/rules/branch-switch-scan.js +0 -132
  282. package/src/core/rules/branch-switch-scan.js.map +0 -1
  283. package/src/core/rules/build-output-pipe-guard.d.ts +0 -56
  284. package/src/core/rules/build-output-pipe-guard.js +0 -120
  285. package/src/core/rules/build-output-pipe-guard.js.map +0 -1
  286. package/src/core/rules/build-output-pipe-scan.d.ts +0 -47
  287. package/src/core/rules/build-output-pipe-scan.js +0 -84
  288. package/src/core/rules/build-output-pipe-scan.js.map +0 -1
  289. package/src/core/rules/cap-remedies.d.ts +0 -39
  290. package/src/core/rules/cap-remedies.js +0 -59
  291. package/src/core/rules/cap-remedies.js.map +0 -1
  292. package/src/core/rules/commit-message-substitution-guard.d.ts +0 -72
  293. package/src/core/rules/commit-message-substitution-guard.js +0 -134
  294. package/src/core/rules/commit-message-substitution-guard.js.map +0 -1
  295. package/src/core/rules/commit-message-substitution-scan.d.ts +0 -42
  296. package/src/core/rules/commit-message-substitution-scan.js +0 -145
  297. package/src/core/rules/commit-message-substitution-scan.js.map +0 -1
  298. package/src/core/rules/content-read-scan.d.ts +0 -76
  299. package/src/core/rules/content-read-scan.js +0 -176
  300. package/src/core/rules/content-read-scan.js.map +0 -1
  301. package/src/core/rules/cure-prefix-scan.d.ts +0 -64
  302. package/src/core/rules/cure-prefix-scan.js +0 -133
  303. package/src/core/rules/cure-prefix-scan.js.map +0 -1
  304. package/src/core/rules/feature-branch-guard.d.ts +0 -121
  305. package/src/core/rules/feature-branch-guard.js +0 -326
  306. package/src/core/rules/feature-branch-guard.js.map +0 -1
  307. package/src/core/rules/judged-tree.d.ts +0 -66
  308. package/src/core/rules/judged-tree.js +0 -97
  309. package/src/core/rules/judged-tree.js.map +0 -1
  310. package/src/core/rules/main-freshness.d.ts +0 -37
  311. package/src/core/rules/main-freshness.js +0 -61
  312. package/src/core/rules/main-freshness.js.map +0 -1
  313. package/src/core/rules/merge-in-progress-guard.d.ts +0 -17
  314. package/src/core/rules/merge-in-progress-guard.js +0 -122
  315. package/src/core/rules/merge-in-progress-guard.js.map +0 -1
  316. package/src/core/rules/merged-branch-bash-guard.d.ts +0 -62
  317. package/src/core/rules/merged-branch-bash-guard.js +0 -170
  318. package/src/core/rules/merged-branch-bash-guard.js.map +0 -1
  319. package/src/core/rules/merged-branch-message.d.ts +0 -59
  320. package/src/core/rules/merged-branch-message.js +0 -137
  321. package/src/core/rules/merged-branch-message.js.map +0 -1
  322. package/src/core/rules/pr-creation-or-push-guard.d.ts +0 -26
  323. package/src/core/rules/pr-creation-or-push-guard.js +0 -146
  324. package/src/core/rules/pr-creation-or-push-guard.js.map +0 -1
  325. package/src/core/rules/pr-merge-guard.d.ts +0 -36
  326. package/src/core/rules/pr-merge-guard.js +0 -86
  327. package/src/core/rules/pr-merge-guard.js.map +0 -1
  328. package/src/core/rules/read-stale-guard.d.ts +0 -136
  329. package/src/core/rules/read-stale-guard.js +0 -326
  330. package/src/core/rules/read-stale-guard.js.map +0 -1
  331. package/src/core/rules/recovery-allowlist.d.ts +0 -49
  332. package/src/core/rules/recovery-allowlist.js +0 -187
  333. package/src/core/rules/recovery-allowlist.js.map +0 -1
  334. package/src/core/rules/redirect-how-to-merge-main.d.ts +0 -16
  335. package/src/core/rules/redirect-how-to-merge-main.js +0 -157
  336. package/src/core/rules/redirect-how-to-merge-main.js.map +0 -1
  337. package/src/core/rules/shell-segment-scan.d.ts +0 -64
  338. package/src/core/rules/shell-segment-scan.js +0 -88
  339. package/src/core/rules/shell-segment-scan.js.map +0 -1
  340. package/src/core/rules/stale-main-bash-guard.d.ts +0 -198
  341. package/src/core/rules/stale-main-bash-guard.js +0 -361
  342. package/src/core/rules/stale-main-bash-guard.js.map +0 -1
  343. package/src/core/rules/stale-main-message.d.ts +0 -62
  344. package/src/core/rules/stale-main-message.js +0 -102
  345. package/src/core/rules/stale-main-message.js.map +0 -1
  346. package/src/core/rules/tree-recovery.d.ts +0 -92
  347. package/src/core/rules/tree-recovery.js +0 -165
  348. package/src/core/rules/tree-recovery.js.map +0 -1
  349. package/src/core/rules/wait-spin-guard.d.ts +0 -128
  350. package/src/core/rules/wait-spin-guard.js +0 -211
  351. package/src/core/rules/wait-spin-guard.js.map +0 -1
  352. package/src/core/rules/wait-spin-scan.d.ts +0 -118
  353. package/src/core/rules/wait-spin-scan.js +0 -203
  354. package/src/core/rules/wait-spin-scan.js.map +0 -1
  355. package/src/core/rules/whole-repo-build-guard.d.ts +0 -125
  356. package/src/core/rules/whole-repo-build-guard.js +0 -257
  357. package/src/core/rules/whole-repo-build-guard.js.map +0 -1
  358. package/src/core/rules/whole-repo-build-scan.d.ts +0 -28
  359. package/src/core/rules/whole-repo-build-scan.js +0 -198
  360. package/src/core/rules/whole-repo-build-scan.js.map +0 -1
  361. package/src/core/session-call-history.d.ts +0 -44
  362. package/src/core/session-call-history.js +0 -79
  363. package/src/core/session-call-history.js.map +0 -1
  364. package/src/core/shell-read-parity.d.ts +0 -56
  365. package/src/core/shell-read-parity.js +0 -155
  366. package/src/core/shell-read-parity.js.map +0 -1
  367. package/src/core/strip-ts-noise.d.ts +0 -1
  368. package/src/core/strip-ts-noise.js +0 -185
  369. package/src/core/strip-ts-noise.js.map +0 -1
  370. package/src/core/sync-main.d.ts +0 -46
  371. package/src/core/sync-main.js +0 -175
  372. package/src/core/sync-main.js.map +0 -1
  373. package/src/core/target-tree.d.ts +0 -84
  374. package/src/core/target-tree.js +0 -148
  375. package/src/core/target-tree.js.map +0 -1
  376. package/src/core/to-error.d.ts +0 -5
  377. package/src/core/to-error.js +0 -37
  378. package/src/core/to-error.js.map +0 -1
  379. package/src/core/types.d.ts +0 -152
  380. package/src/core/types.js +0 -200
  381. package/src/core/types.js.map +0 -1
  382. package/src/core/version-sync.d.ts +0 -219
  383. package/src/core/version-sync.js +0 -558
  384. package/src/core/version-sync.js.map +0 -1
  385. package/src/core/webpieces-versions.d.ts +0 -98
  386. package/src/core/webpieces-versions.js +0 -206
  387. package/src/core/webpieces-versions.js.map +0 -1
  388. package/templates/ai-hook.sh +0 -497
  389. package/templates/claude-settings-hook.json +0 -28
  390. package/templates/webpieces-reviewer.md +0 -60
package/src/core/types.js DELETED
@@ -1,200 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BlockedResult = exports.RuleGroup = exports.FileContext = exports.BashContext = exports.EditContext = exports.Violation = exports.NormalizedToolInput = exports.NormalizedEdit = exports.NormalizedBashInput = exports.InformAiError = exports.RuleFailError = exports.ResolvedRuleConfig = exports.ResolvedConfig = void 0;
4
- var rules_config_1 = require("@webpieces/rules-config");
5
- Object.defineProperty(exports, "ResolvedConfig", { enumerable: true, get: function () { return rules_config_1.ResolvedConfig; } });
6
- Object.defineProperty(exports, "ResolvedRuleConfig", { enumerable: true, get: function () { return rules_config_1.ResolvedRuleConfig; } });
7
- Object.defineProperty(exports, "RuleFailError", { enumerable: true, get: function () { return rules_config_1.RuleFailError; } });
8
- var tooling_common_1 = require("@webpieces/tooling-common");
9
- Object.defineProperty(exports, "InformAiError", { enumerable: true, get: function () { return tooling_common_1.InformAiError; } });
10
- var hook_runtime_1 = require("@webpieces/hook-runtime");
11
- Object.defineProperty(exports, "NormalizedBashInput", { enumerable: true, get: function () { return hook_runtime_1.NormalizedBashInput; } });
12
- Object.defineProperty(exports, "NormalizedEdit", { enumerable: true, get: function () { return hook_runtime_1.NormalizedEdit; } });
13
- Object.defineProperty(exports, "NormalizedToolInput", { enumerable: true, get: function () { return hook_runtime_1.NormalizedToolInput; } });
14
- const l0_fault_codes_1 = require("./l0-fault-codes");
15
- class Violation {
16
- line;
17
- snippet;
18
- // Optional per-occurrence override for the `→` line. When omitted, the report falls back
19
- // to the rule's `FixHint.violation`. Dynamic rules (param name, line count, marker path,
20
- // branch/PR) pass a specific message here; static rules omit it.
21
- message;
22
- editIndex;
23
- editCount;
24
- constructor(line, snippet, message) {
25
- this.line = line;
26
- this.snippet = snippet;
27
- this.message = message;
28
- this.editIndex = undefined;
29
- this.editCount = undefined;
30
- }
31
- }
32
- exports.Violation = Violation;
33
- class EditContext {
34
- tool;
35
- editIndex;
36
- editCount;
37
- filePath;
38
- relativePath;
39
- workspaceRoot;
40
- addedContent;
41
- strippedContent;
42
- lines;
43
- strippedLines;
44
- removedContent;
45
- isLineDisabled;
46
- options;
47
- constructor(tool, editIndex, editCount, filePath, relativePath, workspaceRoot, addedContent, strippedContent, lines, strippedLines, removedContent, isLineDisabled) {
48
- this.tool = tool;
49
- this.editIndex = editIndex;
50
- this.editCount = editCount;
51
- this.filePath = filePath;
52
- this.relativePath = relativePath;
53
- this.workspaceRoot = workspaceRoot;
54
- this.addedContent = addedContent;
55
- this.strippedContent = strippedContent;
56
- this.lines = lines;
57
- this.strippedLines = strippedLines;
58
- this.removedContent = removedContent;
59
- this.isLineDisabled = isLineDisabled;
60
- this.options = {};
61
- }
62
- }
63
- exports.EditContext = EditContext;
64
- // A heredoc and its body: `<<EOF` / `<<'EOF'` / `<<-EOF` through the terminator line.
65
- const HEREDOC_BODY = /<<-?\s*(['"]?)(\w+)\1[\s\S]*?^\t*\2\s*$/gm;
66
- // A single- or double-quoted span.
67
- const QUOTED_SPAN = /'([^']*)'|"([^"]*)"/g;
68
- // Shell syntax that a quoted span is explicitly NOT: separators, pipes, subshells, redirection,
69
- // expansion. Content carrying any of these is data (a jq filter, a regex, a glob), and unquoting it
70
- // would hand the segment scanner syntax the shell never sees. See stripProse.
71
- const SHELL_METACHARACTER = /[|;&()<>$`]/;
72
- class BashContext {
73
- tool;
74
- command;
75
- /**
76
- * `command` with heredoc bodies and prose-in-quotes removed — what a guard should MATCH on, while
77
- * `command` stays raw for the violation message (a human needs to see what they actually typed).
78
- *
79
- * A commit message that merely MENTIONS a blocked command is not that command. This repo's whole
80
- * subject matter is the git workflow, so its commit messages, docs and the guards' own fix-hint
81
- * text are full of `git push` / `gh pr …` strings; matching raw text blocks writing about the
82
- * tooling. A guard that cries wolf is a guard someone eventually turns OFF, which costs far more
83
- * than the theoretical bypass this opens (`sh -c '<blocked command>'` stops matching). That trade
84
- * is deliberate: these guards exist to catch a FORGETFUL agent, not an adversarial one.
85
- *
86
- * ONLY for blocklist-shaped guards ("if the command matches X, block"), where stripping can only
87
- * ever block LESS. Never use it in an allowlist-shaped guard such as merged-branch-bash-guard,
88
- * where stripping could turn a permitted recovery command into a blocked one and deadlock the
89
- * session — there, match on the raw `command`.
90
- */
91
- commandCode;
92
- /**
93
- * The tree this command is JUDGED against — the root of the worktree it actually acts on, which
94
- * is NOT the shell's cwd whenever the command carries a leading `cd <path> &&` (see
95
- * EffectiveTreeResolver). Guards read git state, the main-sync cache and the decision log from
96
- * here, so a command aimed at a linked worktree is judged on that worktree's branch, never the
97
- * primary clone's.
98
- */
99
- workspaceRoot;
100
- /** The directory the command really runs in (post-`cd`). Relative paths resolve against THIS. */
101
- effectiveCwd;
102
- /** The root owning webpieces.config.json. Equals workspaceRoot except in a linked worktree. */
103
- governedRoot;
104
- options;
105
- constructor(command, workspaceRoot, effectiveCwd, governedRoot) {
106
- this.tool = 'Bash';
107
- this.command = command;
108
- this.commandCode = this.stripProse(command);
109
- this.workspaceRoot = workspaceRoot;
110
- this.effectiveCwd = effectiveCwd ?? workspaceRoot;
111
- this.governedRoot = governedRoot ?? workspaceRoot;
112
- this.options = {};
113
- }
114
- /**
115
- * A quoted span WITHOUT whitespace is kept: `git checkout "main"` is a real command with a quoted
116
- * argument, not prose. One containing whitespace is a sentence, and becomes a single space.
117
- *
118
- * ONE exception, and it is a false positive that actually fired: a whitespace-free span carrying
119
- * SHELL METACHARACTERS is dropped too. Keeping the content strips only the quotes, so a jq filter —
120
- * `--jq '[.[]|select(.title|test("x"))]|length'` — was handed to the guards as bare shell syntax.
121
- * Every guard then split it on its `|`, `(` and `;` and saw a segment reading exactly `test`, which
122
- * whole-repo-build-guard classified as the workspace-wide test script and BLOCKED. There was no
123
- * build anywhere in that command; it polled npm and GitHub.
124
- *
125
- * Quoting is precisely how a shell says "this is DATA, not syntax", so honouring the quotes is the
126
- * correct reading. And because commandCode only ever feeds blocklist-shaped guards, dropping more
127
- * can only ever block LESS — never turn an allowed command into a refused one.
128
- */
129
- stripProse(command) {
130
- const withoutHeredocs = command.replace(HEREDOC_BODY, ' ');
131
- return withoutHeredocs.replace(QUOTED_SPAN, (match, single, double) => {
132
- const content = single ?? double ?? '';
133
- if (/\s/.test(content))
134
- return ' ';
135
- return SHELL_METACHARACTER.test(content) ? ' ' : content;
136
- });
137
- }
138
- }
139
- exports.BashContext = BashContext;
140
- class FileContext {
141
- tool;
142
- filePath;
143
- relativePath;
144
- workspaceRoot;
145
- /** The git tree that owns filePath. workspaceRoot remains the root that owns policy/config. */
146
- targetRoot;
147
- /** filePath relative to targetRoot, independent of its governed-root spelling. */
148
- targetRelativePath;
149
- currentFileLines;
150
- linesAdded;
151
- linesRemoved;
152
- projectedFileLines;
153
- options;
154
- constructor(tool, filePath, relativePath, workspaceRoot, currentFileLines, linesAdded, linesRemoved, projectedFileLines, targetRoot = workspaceRoot, targetRelativePath = relativePath) {
155
- this.tool = tool;
156
- this.filePath = filePath;
157
- this.relativePath = relativePath;
158
- this.workspaceRoot = workspaceRoot;
159
- this.targetRoot = targetRoot;
160
- this.targetRelativePath = targetRelativePath;
161
- this.currentFileLines = currentFileLines;
162
- this.linesAdded = linesAdded;
163
- this.linesRemoved = linesRemoved;
164
- this.projectedFileLines = projectedFileLines;
165
- this.options = {};
166
- }
167
- }
168
- exports.FileContext = FileContext;
169
- class RuleGroup {
170
- ruleName;
171
- ruleDescription;
172
- fixHint;
173
- violations;
174
- constructor(ruleName, ruleDescription, fixHint, violations) {
175
- this.ruleName = ruleName;
176
- this.ruleDescription = ruleDescription;
177
- this.fixHint = fixHint;
178
- this.violations = violations;
179
- }
180
- }
181
- exports.RuleGroup = RuleGroup;
182
- class BlockedResult {
183
- report;
184
- /**
185
- * The L0 fault this block IS, in the codebook's own letter (see core/l0-fault-codes.ts), or `-` for
186
- * an ordinary rule block.
187
- *
188
- * It rides on the result rather than being re-derived from the report text because the block is
189
- * decided deep in the runner (fault C in configMissingBlock, fault Y in checkConfigSync) and
190
- * STAMPED by the adapter at the terminal boundary, several frames up. Scraping the report for a
191
- * fault would be a second answer to a question the producer already knows.
192
- */
193
- fault;
194
- constructor(report, fault = l0_fault_codes_1.L0_FAULT_NONE) {
195
- this.report = report;
196
- this.fault = fault;
197
- }
198
- }
199
- exports.BlockedResult = BlockedResult;
200
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/types.ts"],"names":[],"mappings":";;;AAIA,wDAAyG;AAAhG,8GAAA,cAAc,OAAA;AAAE,kHAAA,kBAAkB,OAAA;AAAe,6GAAA,aAAa,OAAA;AACvE,4DAA0D;AAAjD,+GAAA,aAAa,OAAA;AACtB,wDAAuH;AAApG,mHAAA,mBAAmB,OAAA;AAAE,8GAAA,cAAc,OAAA;AAAE,mHAAA,mBAAmB,OAAA;AAE3E,qDAAiD;AAmBjD,MAAa,SAAS;IACT,IAAI,CAAS;IACb,OAAO,CAAS;IACzB,yFAAyF;IACzF,yFAAyF;IACzF,iEAAiE;IACxD,OAAO,CAAqB;IACrC,SAAS,CAAqB;IAC9B,SAAS,CAAqB;IAE9B,YAAY,IAAY,EAAE,OAAe,EAAE,OAAgB;QACvD,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;CACJ;AAjBD,8BAiBC;AAED,MAAa,WAAW;IACX,IAAI,CA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c,EAAE,QAAgB,8BAAa;QACrD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;CACJ;AAjBD,sCAiBC","sourcesContent":["// ResolvedConfig / ResolvedRuleConfig / RuleOptions now live in @webpieces/rules-config\n// so ai-hooks and the Nx validate-code executor share one loader and one config file.\nimport { RuleOptions } from '@webpieces/rules-config';\nimport { HookMode, NormalizedBashInput, NormalizedEdit, NormalizedToolInput, ToolKind } from '@webpieces/hook-runtime';\nexport { ResolvedConfig, ResolvedRuleConfig, RuleOptions, RuleFailError } from '@webpieces/rules-config';\nexport { InformAiError } from '@webpieces/tooling-common';\nexport { HookMode, NormalizedBashInput, NormalizedEdit, NormalizedToolInput, ToolKind } from '@webpieces/hook-runtime';\nimport { FixHint } from './fix-hint';\nimport { L0_FAULT_NONE } from './l0-fault-codes';\n\n// 'Read' is a first-class member because read-stale-guard is a file-scoped guard that runs on the\n// Read fast path. It is deliberately NOT in HANDLED_FILE_TOOLS (adapters/claude-code-adapter.ts), so\n// ClaudeCodeAdapter.kindOf() maps it to the 'Read' routing kind and Read never enters the edit/file\n// rule pipeline — only the one guard that asks for it. Nothing switches exhaustively on this union;\n// it is carried for logging.\n//\n// 'Delete' arrives ONLY from a Codex `apply_patch` carrying a `*** Delete File:` directive — no Claude\n// Code tool produces it. Every existing rule DEFAULTS TO NOT FIRING on it (see DeleteScopedRules in\n// ./delete-scoped-rules.ts): a rule written to judge the bytes an edit ADDS has nothing to say about a file going\n// away, and inventing a verdict for it would be guessing. Rules for which a delete IS meaningful — a\n// barrel export disappearing, a doc that documents a deleted file — opt in there, deliberately.\nexport type RuleScope = 'edit' | 'file' | 'bash';\n// Which category of built-in rules a hook invocation runs: code-style 'rules', git/PR/branch\n// 'guards' (the hookGuards section), or 'all' (both categories — used by the openclaw plugin adapter,\n// which is a single before_tool_call hook rather than two split PreToolUse hooks).\nexport type IsLineDisabled = (lineNum: number, ruleName: string) => boolean;\n\nexport class Violation {\n readonly line: number;\n readonly snippet: string;\n // Optional per-occurrence override for the `→` line. When omitted, the report falls back\n // to the rule's `FixHint.violation`. Dynamic rules (param name, line count, marker path,\n // branch/PR) pass a specific message here; static rules omit it.\n readonly message: string | undefined;\n editIndex: number | undefined;\n editCount: number | undefined;\n\n constructor(line: number, snippet: string, message?: string) {\n this.line = line;\n this.snippet = snippet;\n this.message = message;\n this.editIndex = undefined;\n this.editCount = undefined;\n }\n}\n\nexport class EditContext {\n readonly tool: ToolKind;\n readonly editIndex: number;\n readonly editCount: number;\n readonly filePath: string;\n readonly relativePath: string;\n readonly workspaceRoot: string;\n readonly addedContent: string;\n readonly strippedContent: string;\n readonly lines: readonly string[];\n readonly strippedLines: readonly string[];\n readonly removedContent: string;\n readonly isLineDisabled: IsLineDisabled;\n options: RuleOptions;\n\n constructor(\n tool: ToolKind,\n editIndex: number,\n editCount: number,\n filePath: string,\n relativePath: string,\n workspaceRoot: string,\n addedContent: string,\n strippedContent: string,\n lines: readonly string[],\n strippedLines: readonly string[],\n removedContent: string,\n isLineDisabled: IsLineDisabled,\n ) {\n this.tool = tool;\n this.editIndex = editIndex;\n this.editCount = editCount;\n this.filePath = filePath;\n this.relativePath = relativePath;\n this.workspaceRoot = workspaceRoot;\n this.addedContent = addedContent;\n this.strippedContent = strippedContent;\n this.lines = lines;\n this.strippedLines = strippedLines;\n this.removedContent = removedContent;\n this.isLineDisabled = isLineDisabled;\n this.options = {};\n }\n}\n\n// A heredoc and its body: `<<EOF` / `<<'EOF'` / `<<-EOF` through the terminator line.\nconst HEREDOC_BODY = /<<-?\\s*(['\"]?)(\\w+)\\1[\\s\\S]*?^\\t*\\2\\s*$/gm;\n\n// A single- or double-quoted span.\nconst QUOTED_SPAN = /'([^']*)'|\"([^\"]*)\"/g;\n\n// Shell syntax that a quoted span is explicitly NOT: separators, pipes, subshells, redirection,\n// expansion. Content carrying any of these is data (a jq filter, a regex, a glob), and unquoting it\n// would hand the segment scanner syntax the shell never sees. See stripProse.\nconst SHELL_METACHARACTER = /[|;&()<>$`]/;\n\nexport class BashContext {\n readonly tool: 'Bash';\n readonly command: string;\n /**\n * `command` with heredoc bodies and prose-in-quotes removed — what a guard should MATCH on, while\n * `command` stays raw for the violation message (a human needs to see what they actually typed).\n *\n * A commit message that merely MENTIONS a blocked command is not that command. This repo's whole\n * subject matter is the git workflow, so its commit messages, docs and the guards' own fix-hint\n * text are full of `git push` / `gh pr …` strings; matching raw text blocks writing about the\n * tooling. A guard that cries wolf is a guard someone eventually turns OFF, which costs far more\n * than the theoretical bypass this opens (`sh -c '<blocked command>'` stops matching). That trade\n * is deliberate: these guards exist to catch a FORGETFUL agent, not an adversarial one.\n *\n * ONLY for blocklist-shaped guards (\"if the command matches X, block\"), where stripping can only\n * ever block LESS. Never use it in an allowlist-shaped guard such as merged-branch-bash-guard,\n * where stripping could turn a permitted recovery command into a blocked one and deadlock the\n * session — there, match on the raw `command`.\n */\n readonly commandCode: string;\n /**\n * The tree this command is JUDGED against — the root of the worktree it actually acts on, which\n * is NOT the shell's cwd whenever the command carries a leading `cd <path> &&` (see\n * EffectiveTreeResolver). Guards read git state, the main-sync cache and the decision log from\n * here, so a command aimed at a linked worktree is judged on that worktree's branch, never the\n * primary clone's.\n */\n readonly workspaceRoot: string;\n /** The directory the command really runs in (post-`cd`). Relative paths resolve against THIS. */\n readonly effectiveCwd: string;\n /** The root owning webpieces.config.json. Equals workspaceRoot except in a linked worktree. */\n readonly governedRoot: string;\n options: RuleOptions;\n\n constructor(command: string, workspaceRoot: string, effectiveCwd?: string, governedRoot?: string) {\n this.tool = 'Bash';\n this.command = command;\n this.commandCode = this.stripProse(command);\n this.workspaceRoot = workspaceRoot;\n this.effectiveCwd = effectiveCwd ?? workspaceRoot;\n this.governedRoot = governedRoot ?? workspaceRoot;\n this.options = {};\n }\n\n /**\n * A quoted span WITHOUT whitespace is kept: `git checkout \"main\"` is a real command with a quoted\n * argument, not prose. One containing whitespace is a sentence, and becomes a single space.\n *\n * ONE exception, and it is a false positive that actually fired: a whitespace-free span carrying\n * SHELL METACHARACTERS is dropped too. Keeping the content strips only the quotes, so a jq filter —\n * `--jq '[.[]|select(.title|test(\"x\"))]|length'` — was handed to the guards as bare shell syntax.\n * Every guard then split it on its `|`, `(` and `;` and saw a segment reading exactly `test`, which\n * whole-repo-build-guard classified as the workspace-wide test script and BLOCKED. There was no\n * build anywhere in that command; it polled npm and GitHub.\n *\n * Quoting is precisely how a shell says \"this is DATA, not syntax\", so honouring the quotes is the\n * correct reading. And because commandCode only ever feeds blocklist-shaped guards, dropping more\n * can only ever block LESS — never turn an allowed command into a refused one.\n */\n private stripProse(command: string): string {\n const withoutHeredocs = command.replace(HEREDOC_BODY, ' ');\n return withoutHeredocs.replace(QUOTED_SPAN, (match: string, single?: string, double?: string): string => {\n const content = single ?? double ?? '';\n if (/\\s/.test(content)) return ' ';\n return SHELL_METACHARACTER.test(content) ? ' ' : content;\n });\n }\n}\n\nexport class FileContext {\n readonly tool: ToolKind;\n readonly filePath: string;\n readonly relativePath: string;\n readonly workspaceRoot: string;\n /** The git tree that owns filePath. workspaceRoot remains the root that owns policy/config. */\n readonly targetRoot: string;\n /** filePath relative to targetRoot, independent of its governed-root spelling. */\n readonly targetRelativePath: string;\n readonly currentFileLines: number;\n readonly linesAdded: number;\n readonly linesRemoved: number;\n readonly projectedFileLines: number;\n options: RuleOptions;\n\n constructor(\n tool: ToolKind,\n filePath: string,\n relativePath: string,\n workspaceRoot: string,\n currentFileLines: number,\n linesAdded: number,\n linesRemoved: number,\n projectedFileLines: number,\n targetRoot: string = workspaceRoot,\n targetRelativePath: string = relativePath,\n ) {\n this.tool = tool;\n this.filePath = filePath;\n this.relativePath = relativePath;\n this.workspaceRoot = workspaceRoot;\n this.targetRoot = targetRoot;\n this.targetRelativePath = targetRelativePath;\n this.currentFileLines = currentFileLines;\n this.linesAdded = linesAdded;\n this.linesRemoved = linesRemoved;\n this.projectedFileLines = projectedFileLines;\n this.options = {};\n }\n}\n\n/**\n * The shape of a custom rule loaded from a `rulesDir` (a plain object returned by require()).\n * It carries only metadata + a `check` method — no on/off logic of its own.\n */\nexport interface PlainRule {\n readonly name: string;\n readonly description: string;\n readonly scope: RuleScope;\n readonly files: readonly string[];\n readonly defaultOptions: RuleOptions;\n readonly fixHint: FixHint;\n check(ctx: EditContext | FileContext | BashContext): readonly Violation[];\n}\n\n/**\n * The runtime contract the runner iterates. Both the built-in rule classes (which extend\n * EditRuleBase/FileRuleBase/BashRuleBase) and the custom-rule adapter satisfy this: they add\n * `shouldRun()` (mode + escape-hatch decision) on top of the PlainRule metadata.\n */\nexport interface Rule extends PlainRule {\n /**\n * The webpieces.config.json key whose entry configures this rule — NOT necessarily `name`.\n *\n * `name` is the operator identity (what a decision-log line and a deny report carry); `configKey`\n * is the switch. They differ wherever several classes implement one POLICY: all four branch-state\n * guards read `branch-state-guard`, all four PR-lifecycle guards read `pr-lifecycle-guard`. Every\n * consumer that asks \"which section does this live in?\" (filterByMode) or \"does this have an\n * entry?\" (the fault-Y config-sync check) must read THIS field, because asking for `name` there\n * demands entries under keys the validator rejects as retired.\n */\n readonly configKey: string;\n shouldRun(): boolean;\n}\n\nexport class RuleGroup {\n readonly ruleName: string;\n readonly ruleDescription: string;\n readonly fixHint: FixHint;\n readonly violations: readonly Violation[];\n\n constructor(\n ruleName: string,\n ruleDescription: string,\n fixHint: FixHint,\n violations: readonly Violation[],\n ) {\n this.ruleName = ruleName;\n this.ruleDescription = ruleDescription;\n this.fixHint = fixHint;\n this.violations = violations;\n }\n}\n\nexport class BlockedResult {\n readonly report: string;\n /**\n * The L0 fault this block IS, in the codebook's own letter (see core/l0-fault-codes.ts), or `-` for\n * an ordinary rule block.\n *\n * It rides on the result rather than being re-derived from the report text because the block is\n * decided deep in the runner (fault C in configMissingBlock, fault Y in checkConfigSync) and\n * STAMPED by the adapter at the terminal boundary, several frames up. Scraping the report for a\n * fault would be a second answer to a question the producer already knows.\n */\n readonly fault: string;\n\n constructor(report: string, fault: string = L0_FAULT_NONE) {\n this.report = report;\n this.fault = fault;\n }\n}\n"]}
@@ -1,219 +0,0 @@
1
- import { AiType } from '@webpieces/hook-runtime';
2
- import { EffectiveTree } from './effective-tree';
3
- import { VersionQuartet } from './webpieces-versions';
4
- export declare class VersionSyncGuard {
5
- private readonly inspection;
6
- private readonly versions;
7
- /**
8
- * True when this tree is a linked worktree whose webpieces version disagrees with the main tree's.
9
- * This is the `V` dimension of the L1 matrix; the runner asks it for EVERY Bash call so the answer
10
- * lands in the audit log even when nothing blocks.
11
- */
12
- skewed(tree: EffectiveTree): boolean;
13
- /** The deny report, or null to allow. */
14
- block(command: string, tree: EffectiveTree, aiType: AiType): string | null;
15
- /**
16
- * Commands that must pass EVEN WHILE THIS GUARD IS BLOCKING, because they are how you get unblocked
17
- * — or how you look at the tree first.
18
- *
19
- * `ReadOnlyInspectionScan` deliberately excludes git and gh OUTRIGHT ("the guards exist to police
20
- * git, and read-only git is not a line worth drawing while flying blind"), which is right for the
21
- * guards that police git but WRONG here: this guard's own prescribed cure is `git pull` in both
22
- * trees. Without this carve-out the guard would deny the exact command it tells the reader to run —
23
- * the single failure shape this repo has been burned by most often, and the reason the deny text is
24
- * allowed to promise "STILL ALLOWED HERE: ... pnpm install, git pull/fetch".
25
- *
26
- * Deliberately NARROW: fetching, pulling and installing cannot make a skew worse, and every one of
27
- * them moves the tree toward agreement. Anything that BUILDS, TESTS or COMMITS is still blocked,
28
- * because those are the operations that would be judged by the wrong release.
29
- */
30
- private isCureOrLook;
31
- /**
32
- * Is there a cross-tree comparison to make at all? TWO cheap conditions, no file read behind either:
33
- *
34
- * • K is `worktree` — git's `--git-dir ≠ --git-common-dir`, so a repo with no linked worktrees can
35
- * never reach the manifests. (In the primary clone this is also structural escape #1: "do the
36
- * work in the main tree" needs no allowlist entry to keep working.)
37
- * • the two roots are DIFFERENT directories — a tree compared with itself is not a skew, it is the
38
- * single-tree pin-vs-install question the L0 drift guard already owns.
39
- */
40
- private applies;
41
- /** Public so the runner can log all four versions on ALLOW as well as on BLOCK (audit, not just deny). */
42
- quartetFor(tree: EffectiveTree): VersionQuartet;
43
- private report;
44
- /**
45
- * WHICH of the five states this is — asked ONCE, so the FIX block and the escalation block can never
46
- * describe two different diagnoses of the same skew.
47
- *
48
- * Order is not arbitrary. `main-inconsistent` is asked FIRST because it is a fault in the governing
49
- * tree itself: comparing this worktree against a tree that disagrees with itself picks a direction
50
- * out of two numbers that are not yet one answer. `bump` next, because a deliberate raise is the one
51
- * shape where the direction is real but every ordinary cure is harmful.
52
- */
53
- private classify;
54
- /**
55
- * SEMVER ORDER of two versions: 1 when `a` is newer, -1 when older, 0 when equal OR undecidable.
56
- *
57
- * 0 is the FAIL-SAFE answer and every caller must read it as "no opinion": an unreadable leg, a
58
- * dist-tag, two different pre-releases, or build metadata (which carries no precedence) all land
59
- * there, and `classify` then falls to `main-behind`, the branch that ASKS rather than acts. Guessing
60
- * a direction is how a downgrade gets prescribed, and this repo has already paid for that once.
61
- *
62
- * The same rules the shim's awk compare uses, so L0 and L1 cannot order one pair two ways: build
63
- * metadata stripped, numeric cores compared component-wise, and a pre-release sorting BELOW its
64
- * release.
65
- */
66
- private compare;
67
- /** One version split into its numeric core and its pre-release suffix, or null if it is not numeric. */
68
- private parts;
69
- /**
70
- * The cure list, which is NOT the same list in both directions — but which, in BOTH directions, is a
71
- * list of things the reader ASKS FOR rather than runs.
72
- *
73
- * The ordinary skew is two trees sitting on different commits of main. The pin is tracked, so putting
74
- * both trees on the same commit and installing genuinely converges them. That cure is WRONG, and worse
75
- * than useless, when the branch bumped the pin ON PURPOSE: pulling would revert the deliverable, and
76
- * an install cannot move a pin in either tree. Printing the git cure first in that case is what sent a
77
- * real upgrade agent round the loop below.
78
- *
79
- * WHAT THIS BLOCK IS NOT ALLOWED TO SAY, in either branch: `git -C <the main tree> pull`. Two defects
80
- * rode on that one line, and it was printed ABOVE the escalation block, so it was the first thing read.
81
- * (a) A worktree-isolated SUBAGENT — the overwhelmingly common reader of this deny — CANNOT run
82
- * cross-tree git at all; the harness refuses it (shim-deny-reason.ts records the same
83
- * measurement). The one printed cure was the one thing the reader could not perform.
84
- * (b) A bare `git pull` acts on whatever branch that tree currently has checked out, and the primary
85
- * clone is normally sitting on a feature branch. It pulls the feature branch, the manifest never
86
- * moves, the pin never converges, and this guard fires again. The cure has to NAME main:
87
- * `cd <main> && git checkout main && git pull`.
88
- * So every step is prefixed `Tell main agent:` — INDIVIDUALLY, not under one shared header. That
89
- * repetition is deliberate and is the deliverable: a reader who skims exactly one of these lines must
90
- * still see it is not their own action. Do not factor it out.
91
- *
92
- * The FIX block still prints ABOVE the escalation block, on purpose. Moving it below would split the
93
- * numbered steps from the versions they refer to, and the do-not-retry beat has to stay last and stay
94
- * unique — a second shouted beat competing with it is exactly the wall-of-text regression the L0
95
- * message diet exists to prevent.
96
- * Labelling carries the "not yours to run" fact instead, which is what the caps header does.
97
- */
98
- private fixLines;
99
- /**
100
- * CASE A — the MAIN tree disagrees with ITSELF: its `node_modules` is on one version while its own
101
- * `pnpm-workspace.yaml` pins another. Nothing in this worktree is wrong, and nothing this worktree
102
- * does can help.
103
- *
104
- * The cure is deliberately the SMALL one. The generic branch prints `git checkout main && git pull`
105
- * first, and that is over-prescribed here: both halves of the disagreement are already in that tree,
106
- * so an install materializes the pin it already has and the skew is gone. Printing the pull as well
107
- * invites a main agent to move main's commit for a fault that is not about main's commit at all.
108
- */
109
- private mainInconsistentFix;
110
- /**
111
- * CASE B — the MAIN tree already RUNS a newer release than this tree's pin asks for. This is the
112
- * common case, and it is the one the old message got exactly backwards.
113
- *
114
- * It is the ONLY case a worktree fixes ITSELF. Nothing needs to move in the main tree — the version
115
- * the guards will judge this tree by is already installed there — so the entire fix is to raise this
116
- * tree's own pin to match, which is a one-line edit to a TRACKED file this tree owns. Printing an
117
- * escalation here (as every earlier revision did) tells an agent to stop and wait for a main agent
118
- * who has nothing to do, which is how a five-minute edit became a stalled turn.
119
- *
120
- * The edit is typable from inside the block because pnpm-workspace.yaml is on the L0 allowlist and
121
- * carved out in the runner's edit path. That carve-out and this text ship together on purpose: a
122
- * message prescribing a blocked call is the failure shape this repo has been burned by most often.
123
- *
124
- * ON A DETACHED HEAD the edit has no branch to belong to, so it is not offered — an edit that
125
- * survives nothing is worse than no edit. Get onto a branch, then read this message again.
126
- */
127
- private mainAheadFix;
128
- /**
129
- * Is HEAD DETACHED in this tree — i.e. is there no branch for a pin edit to belong to?
130
- *
131
- * `branch --show-current`, NOT `rev-parse --abbrev-ref HEAD`: it answers on an UNBORN branch (which
132
- * every freshly-created worktree is until its first commit, and where `rev-parse` fatals) and prints
133
- * EMPTY on a detached HEAD, which is exactly the distinction case B needs.
134
- *
135
- * A git FAILURE is NOT detached, and the difference is load-bearing: `--show-current` prints nothing
136
- * in both situations, so keying off the output alone would tell anyone whose tree git cannot read
137
- * (no repo, a broken index, git absent) that their HEAD is detached — a confident diagnosis of a
138
- * state nobody measured. Only an exit-0-with-empty-output is detached; anything else falls back to
139
- * the ordinary branch wording, whose worst case is prescribing an edit that turns out to be moot.
140
- */
141
- private isDetachedHead;
142
- /**
143
- * THE SUBAGENT CANNOT REACH THE MAIN TREE, so the message it is handed has to be the message it
144
- * FORWARDS. This used to be one sentence — "report to your coordinator that one of you must move to
145
- * the other's version" — with no command, no direction and nothing pasteable, and the result was a
146
- * subagent that correctly diagnosed the block, correctly escalated, and handed its coordinator a
147
- * request too vague to act on. Worse, the obvious guess ("ask the coordinator to run `pnpm install`
148
- * in main") is a NO-OP on a bump: it reinstalls main's own pin and nothing moves.
149
- *
150
- * So the escalation is rendered as literal text to forward, with the versions and the direction
151
- * already filled in. A human cannot sit with every agent; the deny has to carry the whole ask.
152
- *
153
- * The ask is ROUTED THROUGH THE MAIN AGENT rather than phrased as a command, and that distinction is
154
- * the whole point of this block. `git -C <mainRoot> pull` reads like something you run from wherever
155
- * you are standing — so a subagent reads it, tries it, and only then discovers that CROSS-TREE GIT IS
156
- * REFUSED to a worktree-isolated agent (same measurement shim-deny-reason.ts records: the harness
157
- * blocks `git -C <other tree>`, and it is git specifically). This skew needs a git pull in main, so
158
- * the one printed cure was the one thing this session cannot perform. Be precise about that and do
159
- * NOT overstate it into "you cannot reach that tree at all" — a local `cd <main> && pnpm install`
160
- * measurably DOES run, it simply cannot move main onto a different commit, which is what a skew
161
- * requires. The actor who can is the MAIN AGENT running in the MAIN git worktree, so the forwarded
162
- * text asks for exactly that — and asks to be TOLD WHEN IT IS DONE, because "the work happened" is
163
- * the event that unblocks this subagent and it has no way to observe it otherwise.
164
- *
165
- * And it has to refuse the RETRY, because forwarding is only half of what the subagent must do. One
166
- * measured subagent transcript re-fired this identical deny 13 TIMES (25 across the whole session,
167
- * counting two sibling subagents and two parent sessions): the subagent read it, escalated exactly
168
- * as asked — and then re-ran the blocked call. Every retry cost a round trip and pushed the one
169
- * message that mattered further up the scrollback. The block is not transient and no command from
170
- * this tree slips past it, so retrying is never a strategy; it is the bug.
171
- *
172
- * What it must NOT do is decide the agent's control flow. #679 first wrote this beat as "STOP WORKING
173
- * NOW. Forwarding that message IS the end of your turn: make NO further tool calls" — a turn-level
174
- * prescription, which `.claude/rules/never-tell-an-ai-to-end-its-turn.md` forbids (#902 deleted every
175
- * other one; this one survived because no spec rendered it — issue #1000). Refusing one futile
176
- * command is legitimate; ruling on when the turn ends is a judgement the agent is better placed to
177
- * make. So the beat names the retry, says why it is futile, and stops talking.
178
- */
179
- private escalationLines;
180
- /**
181
- * What the coordinator does ONCE main is synced — and here the two harnesses need opposite answers.
182
- *
183
- * Codex runs every subagent in the coordinator's own checkout, so "tell me when it is done so I can
184
- * continue" is literally true: the same agent picks up where it stopped.
185
- *
186
- * Claude Code does NOT keep that tree for it. A worktree-isolated subagent that hands back with an
187
- * unchanged worktree has that worktree REAPED, and a subagent resumed afterwards (SendMessage) comes
188
- * back with its cwd on the PRIMARY clone — which happened to the first agent on issue #863 itself. So
189
- * asking to be resumed routes the work into the one tree it must never land in. The ask is therefore a
190
- * FRESH `isolation: "worktree"` subagent, and "resume me" / "continue working" must not appear.
191
- */
192
- private afterwardLines;
193
- private waitLines;
194
- /**
195
- * The forwardable ASK, one per case that needs one. `main-ahead` never reaches here — it has nothing
196
- * to ask for — so the three shapes below cover every escalating case. What happens AFTER the ask is
197
- * harness-specific and lives in {@link afterwardLines}, so none of these says "tell me when".
198
- *
199
- * The bump ask carries the upgrade sentence VERBATIM as Dean wrote it, because it answers the one
200
- * question an upgrade agent gets wrong: "webpieces cannot be upgraded from a worktree" is not a
201
- * missing permission it can route around, it is a property of who governs whom.
202
- */
203
- private askLines;
204
- /**
205
- * Did THIS BRANCH change the pin, as opposed to the two trees having drifted onto different commits?
206
- *
207
- * Only answerable now that both pin legs actually resolve — before the catalog reader followed YAML
208
- * anchors they both read null on the repos that pin via an anchor, so every skew looked alike and the
209
- * report could only ever print the one generic cure.
210
- *
211
- * Two git spawns worst case, on the BLOCK path only (this is never reached on an allow), and
212
- * best-effort: a git failure answers "not a deliberate bump", which falls back to the generic cure
213
- * that was the only text this report had before.
214
- */
215
- private isDeliberateBump;
216
- private touchesWorkspaceFile;
217
- private versionLines;
218
- private show;
219
- }