@webpieces/ai-hook-rules 0.4.839 → 0.4.841

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
@@ -1,135 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.REVIEWER_AGENT_TEMPLATE = exports.REVIEWER_AGENT_MARKER = exports.REVIEWER_AGENT_NAME = void 0;
4
- exports.reviewerAgentPath = reviewerAgentPath;
5
- exports.renderReviewerAgent = renderReviewerAgent;
6
- exports.reviewerAgentStale = reviewerAgentStale;
7
- exports.writeReviewerAgent = writeReviewerAgent;
8
- const tslib_1 = require("tslib");
9
- const fs = tslib_1.__importStar(require("fs"));
10
- const path = tslib_1.__importStar(require("path"));
11
- const shim_1 = require("./shim");
12
- // ---------------------------------------------------------------------------
13
- // THE GENERIC REVIEWER AGENT — `.claude/agents/webpieces-reviewer.md`, a webpieces-owned, committed file
14
- // (issue #938).
15
- //
16
- // Every PR-gate checklist used to name its OWN agent type, one `.claude/agents/<name>-reviewer.md` each.
17
- // Those files added almost nothing over the checklist doc — a tool restriction and a paragraph saying
18
- // "read your instructions file" — were annoying to author per checklist, and drifted (#863: Codex never
19
- // read them at all). They also forced one subagent per checklist. So a repo now names ONE agent type in
20
- // `commands.pr-gate` (`webpieces-reviewer` unless `overrideReviewerAgent` is true), and this is the one webpieces ships: checklist-agnostic, because
21
- // everything checklist-specific is in the per-run instructions files `wp-review-upsert-pr` generates.
22
- //
23
- // It is a MANAGED SURFACE, exactly like `.claude/webpieces/ai-hook.sh`: GENERATED from
24
- // renderReviewerAgent(), byte-STABLE across releases (no version stamp, so it changes only when its own
25
- // words do), written by `wp-install-ai-hooks` and `wp-upgrade-shim`, and checked by managedSurfaceDrift()
26
- // so a missing, stale or hand-edited copy is flagged with `pnpm wp-upgrade-shim` as the cure. A repo
27
- // that wants different words sets `"overrideReviewerAgent": true` and `reviewerAgentName` to an agent of its
28
- // own instead of editing this.
29
- //
30
- // fs + path + ./shim only, like the rest of this directory: the cure must run on a tree too broken to
31
- // load the rule engine.
32
- // ---------------------------------------------------------------------------
33
- /** The agent type this file registers — the reviewer every repo gets unless it sets `overrideReviewerAgent`. */
34
- exports.REVIEWER_AGENT_NAME = 'webpieces-reviewer';
35
- /** The committed file, repo-relative — also the name the drift check reports it under. */
36
- exports.REVIEWER_AGENT_MARKER = `.claude/agents/${exports.REVIEWER_AGENT_NAME}.md`;
37
- /** The copy that ships in the package, byte-identical to renderReviewerAgent() (locked by a unit test). */
38
- exports.REVIEWER_AGENT_TEMPLATE = `${exports.REVIEWER_AGENT_NAME}.md`;
39
- // webpieces-disable no-function-outside-class -- pure fs+path helper beside shimPath, in the dependency-free bin module
40
- function reviewerAgentPath(projectRoot) {
41
- return path.join(projectRoot, ...exports.REVIEWER_AGENT_MARKER.split('/'));
42
- }
43
- // webpieces-disable no-function-outside-class -- pure renderer beside renderShim, in the dependency-free bin module
44
- function renderReviewerAgent() {
45
- return `---
46
- name: ${exports.REVIEWER_AGENT_NAME}
47
- description: Generic PR-gate reviewer. Reviews a diff against one or more checklist docs, each over its own in-scope files, and submits exactly one verdict per checklist through pnpm wp-write-review. Spawned by \`pnpm wp-review-upsert-pr\`, which names the instructions files to read. Never edits code.
48
- tools: Read, Grep, Glob, Bash, Write
49
- ---
50
-
51
- <!-- Generated by webpieces (@webpieces/ai-hook-rules) — do not edit; regenerate with pnpm wp-upgrade-shim.
52
- To change how reviews are done, set commands.pr-gate "overrideReviewerAgent": true and "reviewerAgentName" to an agent of your own. -->
53
-
54
- You are a PR-gate reviewer. You did not write this change, and your job is to judge it against the
55
- checklist(s) you are handed — nothing else.
56
-
57
- ## What you are given
58
-
59
- Your caller names ONE OR MORE instructions files by absolute path, one per checklist
60
- (\`<checklist-id>.instructions.md\`). Read every one of them FIRST. Each is regenerated on every run and
61
- holds, for its checklist:
62
-
63
- - the checklist doc to review against — the substance of that review;
64
- - the files in scope, each with its extracted diff and the absolute path of the full source;
65
- - the diff manifest, the diff basis, and any pre-resolved context for this repo;
66
- - the exact verdict format, and the exact command that submits it.
67
-
68
- Work only from those files. Nothing about any checklist is restated here, so nothing here can drift.
69
-
70
- ## Before you review: the round budget
71
-
72
- For EACH checklist you were handed, run \`pnpm wp-write-review --checklist <id> --check\` first. It confirms
73
- the round is within the repository's \`maxReviewerRounds\` and that the checklist has no verdict yet in this
74
- round, and it says when this is the FINAL round. When it REFUSES, do not review that checklist and submit
75
- nothing for it: report its refusal verbatim to your caller ("I am not allowed to review <id>: …").
76
- \`wp-write-review\` refuses an over-budget verdict anyway, so a review past the budget is wasted work that
77
- cannot be recorded.
78
-
79
- On the FINAL round there is no re-review, so there is no red: mark anything that must be fixed ORANGE, with
80
- a concrete, actionable fix — the author applies it best effort and ships without another review, so put
81
- every finding in now. Before the final round, a must-fix is RED and the author's fix is reviewed again.
82
- Your instructions file says which round this is.
83
-
84
- ## How to review
85
-
86
- 1. Handle each checklist SEPARATELY. Read its doc, then its in-scope diffs, then the full source of every
87
- in-scope file — a hunk shows what changed, only the whole file shows what it changed into.
88
- 2. Judge each checklist ONLY against its own in-scope files. A finding that belongs to another checklist
89
- is not a finding for this one; a matched file that turns out to be irrelevant gets one sentence.
90
- 3. Read other files for context when a judgement needs it, but do not go hunting: no searches through
91
- \`node_modules\`, no re-deriving the dependency graph. If something you need is missing, say so in
92
- \`output\` and judge what you could see.
93
-
94
- ## What you submit
95
-
96
- Exactly ONE verdict per checklist you were handed — and nothing for a checklist you were not handed —
97
- in the format its instructions file gives, submitted through \`pnpm wp-write-review --checklist <id>\`
98
- with the verdict JSON on stdin (a heredoc is simplest), or \`--file <path>\` naming a scratch file. It validates
99
- it, writes the verdict file, and records that YOU wrote it. A verdict file written any other way —
100
- by you, or by the coordinating agent on your behalf — is rejected by the gate, so there is no other route.
101
-
102
- You NEVER edit code, config, docs, or any other file in the repo. You never write \`summary.json\` or an
103
- \`override-<id>.json\`. If a finding needs a human's decision, say so in \`output\`; the coordinating
104
- agent is the one with the human.
105
- `;
106
- }
107
- /**
108
- * True when this tree is webpieces-hooked (its committed shim exists) and the reviewer agent is MISSING or
109
- * differs from renderReviewerAgent(). Gated on the shim for the same reason `committedShimStale` is gated
110
- * on its own file: a tree webpieces never installed into has no managed surface to police.
111
- */
112
- // webpieces-disable no-function-outside-class -- pure fs+path helper beside committedShimStale, in the dependency-free bin module
113
- function reviewerAgentStale(root) {
114
- if (root === null || !fs.existsSync((0, shim_1.shimPath)(root)))
115
- return false;
116
- const target = reviewerAgentPath(root);
117
- if (!fs.existsSync(target))
118
- return true;
119
- return fs.readFileSync(target, 'utf8') !== renderReviewerAgent();
120
- }
121
- /**
122
- * Write the reviewer agent under `root`, returning true when the file changed. Creates `.claude/agents/`
123
- * when it is absent — that directory is what a Claude Code session scans for agent types.
124
- */
125
- // webpieces-disable no-function-outside-class -- pure fs+path writer beside writeShim, in the dependency-free bin module
126
- function writeReviewerAgent(root) {
127
- const target = reviewerAgentPath(root);
128
- const desired = renderReviewerAgent();
129
- if (fs.existsSync(target) && fs.readFileSync(target, 'utf8') === desired)
130
- return false;
131
- fs.mkdirSync(path.dirname(target), { recursive: true });
132
- fs.writeFileSync(target, desired);
133
- return true;
134
- }
135
- //# sourceMappingURL=reviewer-agent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"reviewer-agent.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/reviewer-agent.ts"],"names":[],"mappings":";;;AAqCA,8CAEC;AAGD,kDA8DC;AAQD,gDAKC;AAOD,gDAOC;;AAnID,+CAAyB;AACzB,mDAA6B;AAE7B,iCAAkC;AAElC,8EAA8E;AAC9E,yGAAyG;AACzG,gBAAgB;AAChB,EAAE;AACF,yGAAyG;AACzG,sGAAsG;AACtG,wGAAwG;AACxG,wGAAwG;AACxG,qJAAqJ;AACrJ,sGAAsG;AACtG,EAAE;AACF,uFAAuF;AACvF,wGAAwG;AACxG,0GAA0G;AAC1G,qGAAqG;AACrG,6GAA6G;AAC7G,+BAA+B;AAC/B,EAAE;AACF,sGAAsG;AACtG,wBAAwB;AACxB,8EAA8E;AAE9E,gHAAgH;AACnG,QAAA,mBAAmB,GAAG,oBAAoB,CAAC;AAExD,0FAA0F;AAC7E,QAAA,qBAAqB,GAAG,kBAAkB,2BAAmB,KAAK,CAAC;AAEhF,2GAA2G;AAC9F,QAAA,uBAAuB,GAAG,GAAG,2BAAmB,KAAK,CAAC;AAEnE,wHAAwH;AACxH,SAAgB,iBAAiB,CAAC,WAAmB;IACjD,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,6BAAqB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AACvE,CAAC;AAED,oHAAoH;AACpH,SAAgB,mBAAmB;IAC/B,OAAO;QACH,2BAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2D1B,CAAC;AACF,CAAC;AAED;;;;GAIG;AACH,kIAAkI;AAClI,SAAgB,kBAAkB,CAAC,IAAmB;IAClD,IAAI,IAAI,KAAK,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAA,eAAQ,EAAC,IAAI,CAAC,CAAC;QAAE,OAAO,KAAK,CAAC;IAClE,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,mBAAmB,EAAE,CAAC;AACrE,CAAC;AAED;;;GAGG;AACH,yHAAyH;AACzH,SAAgB,kBAAkB,CAAC,IAAY;IAC3C,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,MAAM,OAAO,GAAG,mBAAmB,EAAE,CAAC;IACtC,IAAI,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IACvF,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACxD,EAAE,CAAC,aAAa,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,OAAO,IAAI,CAAC;AAChB,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport { shimPath } from './shim';\n\n// ---------------------------------------------------------------------------\n// THE GENERIC REVIEWER AGENT — `.claude/agents/webpieces-reviewer.md`, a webpieces-owned, committed file\n// (issue #938).\n//\n// Every PR-gate checklist used to name its OWN agent type, one `.claude/agents/<name>-reviewer.md` each.\n// Those files added almost nothing over the checklist doc — a tool restriction and a paragraph saying\n// \"read your instructions file\" — were annoying to author per checklist, and drifted (#863: Codex never\n// read them at all). They also forced one subagent per checklist. So a repo now names ONE agent type in\n// `commands.pr-gate` (`webpieces-reviewer` unless `overrideReviewerAgent` is true), and this is the one webpieces ships: checklist-agnostic, because\n// everything checklist-specific is in the per-run instructions files `wp-review-upsert-pr` generates.\n//\n// It is a MANAGED SURFACE, exactly like `.claude/webpieces/ai-hook.sh`: GENERATED from\n// renderReviewerAgent(), byte-STABLE across releases (no version stamp, so it changes only when its own\n// words do), written by `wp-install-ai-hooks` and `wp-upgrade-shim`, and checked by managedSurfaceDrift()\n// so a missing, stale or hand-edited copy is flagged with `pnpm wp-upgrade-shim` as the cure. A repo\n// that wants different words sets `\"overrideReviewerAgent\": true` and `reviewerAgentName` to an agent of its\n// own instead of editing this.\n//\n// fs + path + ./shim only, like the rest of this directory: the cure must run on a tree too broken to\n// load the rule engine.\n// ---------------------------------------------------------------------------\n\n/** The agent type this file registers — the reviewer every repo gets unless it sets `overrideReviewerAgent`. */\nexport const REVIEWER_AGENT_NAME = 'webpieces-reviewer';\n\n/** The committed file, repo-relative — also the name the drift check reports it under. */\nexport const REVIEWER_AGENT_MARKER = `.claude/agents/${REVIEWER_AGENT_NAME}.md`;\n\n/** The copy that ships in the package, byte-identical to renderReviewerAgent() (locked by a unit test). */\nexport const REVIEWER_AGENT_TEMPLATE = `${REVIEWER_AGENT_NAME}.md`;\n\n// webpieces-disable no-function-outside-class -- pure fs+path helper beside shimPath, in the dependency-free bin module\nexport function reviewerAgentPath(projectRoot: string): string {\n return path.join(projectRoot, ...REVIEWER_AGENT_MARKER.split('/'));\n}\n\n// webpieces-disable no-function-outside-class -- pure renderer beside renderShim, in the dependency-free bin module\nexport function renderReviewerAgent(): string {\n return `---\nname: ${REVIEWER_AGENT_NAME}\ndescription: Generic PR-gate reviewer. Reviews a diff against one or more checklist docs, each over its own in-scope files, and submits exactly one verdict per checklist through pnpm wp-write-review. Spawned by \\`pnpm wp-review-upsert-pr\\`, which names the instructions files to read. Never edits code.\ntools: Read, Grep, Glob, Bash, Write\n---\n\n<!-- Generated by webpieces (@webpieces/ai-hook-rules) — do not edit; regenerate with pnpm wp-upgrade-shim.\n To change how reviews are done, set commands.pr-gate \"overrideReviewerAgent\": true and \"reviewerAgentName\" to an agent of your own. -->\n\nYou are a PR-gate reviewer. You did not write this change, and your job is to judge it against the\nchecklist(s) you are handed — nothing else.\n\n## What you are given\n\nYour caller names ONE OR MORE instructions files by absolute path, one per checklist\n(\\`<checklist-id>.instructions.md\\`). Read every one of them FIRST. Each is regenerated on every run and\nholds, for its checklist:\n\n- the checklist doc to review against — the substance of that review;\n- the files in scope, each with its extracted diff and the absolute path of the full source;\n- the diff manifest, the diff basis, and any pre-resolved context for this repo;\n- the exact verdict format, and the exact command that submits it.\n\nWork only from those files. Nothing about any checklist is restated here, so nothing here can drift.\n\n## Before you review: the round budget\n\nFor EACH checklist you were handed, run \\`pnpm wp-write-review --checklist <id> --check\\` first. It confirms\nthe round is within the repository's \\`maxReviewerRounds\\` and that the checklist has no verdict yet in this\nround, and it says when this is the FINAL round. When it REFUSES, do not review that checklist and submit\nnothing for it: report its refusal verbatim to your caller (\"I am not allowed to review <id>: …\").\n\\`wp-write-review\\` refuses an over-budget verdict anyway, so a review past the budget is wasted work that\ncannot be recorded.\n\nOn the FINAL round there is no re-review, so there is no red: mark anything that must be fixed ORANGE, with\na concrete, actionable fix — the author applies it best effort and ships without another review, so put\nevery finding in now. Before the final round, a must-fix is RED and the author's fix is reviewed again.\nYour instructions file says which round this is.\n\n## How to review\n\n1. Handle each checklist SEPARATELY. Read its doc, then its in-scope diffs, then the full source of every\n in-scope file — a hunk shows what changed, only the whole file shows what it changed into.\n2. Judge each checklist ONLY against its own in-scope files. A finding that belongs to another checklist\n is not a finding for this one; a matched file that turns out to be irrelevant gets one sentence.\n3. Read other files for context when a judgement needs it, but do not go hunting: no searches through\n \\`node_modules\\`, no re-deriving the dependency graph. If something you need is missing, say so in\n \\`output\\` and judge what you could see.\n\n## What you submit\n\nExactly ONE verdict per checklist you were handed — and nothing for a checklist you were not handed —\nin the format its instructions file gives, submitted through \\`pnpm wp-write-review --checklist <id>\\`\nwith the verdict JSON on stdin (a heredoc is simplest), or \\`--file <path>\\` naming a scratch file. It validates\nit, writes the verdict file, and records that YOU wrote it. A verdict file written any other way —\nby you, or by the coordinating agent on your behalf — is rejected by the gate, so there is no other route.\n\nYou NEVER edit code, config, docs, or any other file in the repo. You never write \\`summary.json\\` or an\n\\`override-<id>.json\\`. If a finding needs a human's decision, say so in \\`output\\`; the coordinating\nagent is the one with the human.\n`;\n}\n\n/**\n * True when this tree is webpieces-hooked (its committed shim exists) and the reviewer agent is MISSING or\n * differs from renderReviewerAgent(). Gated on the shim for the same reason `committedShimStale` is gated\n * on its own file: a tree webpieces never installed into has no managed surface to police.\n */\n// webpieces-disable no-function-outside-class -- pure fs+path helper beside committedShimStale, in the dependency-free bin module\nexport function reviewerAgentStale(root: string | null): boolean {\n if (root === null || !fs.existsSync(shimPath(root))) return false;\n const target = reviewerAgentPath(root);\n if (!fs.existsSync(target)) return true;\n return fs.readFileSync(target, 'utf8') !== renderReviewerAgent();\n}\n\n/**\n * Write the reviewer agent under `root`, returning true when the file changed. Creates `.claude/agents/`\n * when it is absent — that directory is what a Claude Code session scans for agent types.\n */\n// webpieces-disable no-function-outside-class -- pure fs+path writer beside writeShim, in the dependency-free bin module\nexport function writeReviewerAgent(root: string): boolean {\n const target = reviewerAgentPath(root);\n const desired = renderReviewerAgent();\n if (fs.existsSync(target) && fs.readFileSync(target, 'utf8') === desired) return false;\n fs.mkdirSync(path.dirname(target), { recursive: true });\n fs.writeFileSync(target, desired);\n return true;\n}\n"]}
@@ -1,37 +0,0 @@
1
- /**
2
- * THE SETTINGS-FILE SHAPE — one declaration of it, in a LEAF module that imports nothing.
3
- *
4
- * MEASURED: Codex's `.codex/hooks.json` uses the IDENTICAL `hooks.<event>[].hooks[].command` shape as
5
- * Claude Code's `.claude/settings.json`, so one reader, one writer and one repair serve both files —
6
- * the difference between the harnesses is entirely in the VALUES (matcher, shim anchor), which is what
7
- * `HarnessRegistration` carries. The `env` block is Claude Code's alone.
8
- *
9
- * It sits in its own file because two modules need it and one of them, `hook-registration.ts`, imports
10
- * the repairs from the other, `neighbour-hooks.ts`. Declaring the shape in either one would close a file
11
- * import cycle — which `validate-no-file-import-cycles` fails the build on, and which is a genuine
12
- * hazard in this bin layer, where every module must still load on a tree too broken to build anything.
13
- * A leaf both can point at costs one file and removes the choice.
14
- */
15
- export interface HookCommand {
16
- type: string;
17
- command: string;
18
- }
19
- export interface HookEntry {
20
- matcher: string;
21
- hooks: HookCommand[];
22
- }
23
- /**
24
- * The `hooks` block, keyed by EVENT. `PreToolUse` is named because every webpieces-managed entry lives
25
- * there; the index signature is what lets the neighbour-anchoring pass reach `PostToolUse`, `Stop` and
26
- * everything else — a relative entry path fails to load under any event, so a repair scoped to one of
27
- * them would leave a half-fixed file and report success.
28
- */
29
- export interface HookEvents {
30
- PreToolUse?: HookEntry[];
31
- [event: string]: HookEntry[] | undefined;
32
- }
33
- export interface ClaudeSettings {
34
- hooks?: HookEvents;
35
- env?: Record<string, string>;
36
- [key: string]: unknown;
37
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- /**
3
- * THE SETTINGS-FILE SHAPE — one declaration of it, in a LEAF module that imports nothing.
4
- *
5
- * MEASURED: Codex's `.codex/hooks.json` uses the IDENTICAL `hooks.<event>[].hooks[].command` shape as
6
- * Claude Code's `.claude/settings.json`, so one reader, one writer and one repair serve both files —
7
- * the difference between the harnesses is entirely in the VALUES (matcher, shim anchor), which is what
8
- * `HarnessRegistration` carries. The `env` block is Claude Code's alone.
9
- *
10
- * It sits in its own file because two modules need it and one of them, `hook-registration.ts`, imports
11
- * the repairs from the other, `neighbour-hooks.ts`. Declaring the shape in either one would close a file
12
- * import cycle — which `validate-no-file-import-cycles` fails the build on, and which is a genuine
13
- * hazard in this bin layer, where every module must still load on a tree too broken to build anything.
14
- * A leaf both can point at costs one file and removes the choice.
15
- */
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- //# sourceMappingURL=settings-shape.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"settings-shape.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/settings-shape.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG","sourcesContent":["/**\n * THE SETTINGS-FILE SHAPE — one declaration of it, in a LEAF module that imports nothing.\n *\n * MEASURED: Codex's `.codex/hooks.json` uses the IDENTICAL `hooks.<event>[].hooks[].command` shape as\n * Claude Code's `.claude/settings.json`, so one reader, one writer and one repair serve both files —\n * the difference between the harnesses is entirely in the VALUES (matcher, shim anchor), which is what\n * `HarnessRegistration` carries. The `env` block is Claude Code's alone.\n *\n * It sits in its own file because two modules need it and one of them, `hook-registration.ts`, imports\n * the repairs from the other, `neighbour-hooks.ts`. Declaring the shape in either one would close a file\n * import cycle — which `validate-no-file-import-cycles` fails the build on, and which is a genuine\n * hazard in this bin layer, where every module must still load on a tree too broken to build anything.\n * A leaf both can point at costs one file and removes the choice.\n */\n\n// webpieces-disable no-any-unknown -- settings.json is opaque consumer JSON\nexport interface HookCommand { type: string; command: string; }\n\nexport interface HookEntry { matcher: string; hooks: HookCommand[]; }\n\n/**\n * The `hooks` block, keyed by EVENT. `PreToolUse` is named because every webpieces-managed entry lives\n * there; the index signature is what lets the neighbour-anchoring pass reach `PostToolUse`, `Stop` and\n * everything else — a relative entry path fails to load under any event, so a repair scoped to one of\n * them would leave a half-fixed file and report success.\n */\nexport interface HookEvents {\n PreToolUse?: HookEntry[];\n [event: string]: HookEntry[] | undefined;\n}\n\nexport interface ClaudeSettings {\n hooks?: HookEvents;\n // Claude Code's settings `env` block: every key is exported into the environment of the session AND\n // of every subagent it spawns. That inheritance is precisely why webpieces pins its managed entry\n // here rather than in a shell profile — see managed-env.ts.\n env?: Record<string, string>;\n // webpieces-disable no-any-unknown -- opaque settings bag; arbitrary keys allowed\n [key: string]: unknown;\n}\n"]}
@@ -1,19 +0,0 @@
1
- type Json = Record<string, unknown>;
2
- type RuleEntry = Json;
3
- type Section = Record<string, RuleEntry>;
4
- interface ConfigFile {
5
- extends?: string;
6
- rules: Section;
7
- hookGuards: Section;
8
- commands: Json;
9
- excludePaths: string[];
10
- 'match-rules': Json[];
11
- rulesDir: string[];
12
- }
13
- interface MigrateResult {
14
- config: ConfigFile;
15
- changes: string[];
16
- }
17
- export declare function migrate(existing: Json): MigrateResult;
18
- export declare function seedOrSyncConfig(projectRoot: string): void;
19
- export {};
@@ -1,370 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.migrate = migrate;
4
- exports.seedOrSyncConfig = seedOrSyncConfig;
5
- const tslib_1 = require("tslib");
6
- const fs = tslib_1.__importStar(require("fs"));
7
- const path = tslib_1.__importStar(require("path"));
8
- const rules_config_1 = require("@webpieces/rules-config");
9
- const to_error_1 = require("../core/to-error");
10
- /**
11
- * SEEDING AND MIGRATING `webpieces.config.json` — the installer's OTHER job.
12
- *
13
- * Split out of ./setup.ts purely for size, and along the seam that was already there: setup.ts is now
14
- * hook WIRING (which settings file gets which matcher and which shim command) and this module is CONFIG
15
- * SHAPE (which rules exist, where a retired key moves to). They share only `main()`, which calls this
16
- * once and then wires the hooks.
17
- *
18
- * Like setup.ts it is deliberately DI-FREE: `wp-install-ai-hooks` has to run on a half-written
19
- * node_modules (see install-entry.ts), so every function here is module-scope and imports nothing that
20
- * needs a container.
21
- */
22
- const CONFIG_FILENAME = 'webpieces.config.json';
23
- // The seeded buildCommand comes from @webpieces/rules-config, NOT from a copy here. This file used to
24
- // hold its own — with `--base=origin/main`, a DIFFERENT base from the one the gate documents — so a
25
- // freshly set-up repo was seeded with a command that rebuilds projects touched by other people's
26
- // merged PRs, and whole-repo-build-guard then quoted that command back in its refusals.
27
- const DEFAULT_UPSERT_PR = 'pnpm wp-start-upsert-pr';
28
- const DEFAULT_MERGE_COMPLETE = 'pnpm wp-finish-upsert-pr';
29
- // webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design
30
- function seedRule(ruleName) {
31
- // Both escape hatches are seeded (and REQUIRED) so every rule block shows them: 0 = active,
32
- // null = no branch scoping. A human/AI edits these to time-box or branch-scope a rule off.
33
- //
34
- // The ENTIRE entry comes from rules-config's seedEntryForRule() — the same module that owns the
35
- // schema the loader validates against, so the installer can never emit an entry the loader
36
- // rejects. It supplies: the recommended mode (the SAME recommendation the validator prints in its
37
- // copy-paste snippet, so seed and advice cannot disagree), both hatches, and a default for every
38
- // other schema-REQUIRED field. Seeding used to be a flat 'OFF' plus the two hatches, which was
39
- // wrong twice over: adopters got nothing enforced, AND the entry was missing required fields
40
- // (e.g. branch-creation-guard.autoReapMergedBranches), so the config failed to load on first run.
41
- return (0, rules_config_1.seedEntryForRule)(ruleName);
42
- }
43
- // The guard-hint command strings live under `guardHints`. The flat `upsertPr`/`mergeComplete` keys this
44
- // used to seed are RETIRED and now fail validation — seeding them meant every freshly installed repo was
45
- // born on a shape the validator rejects.
46
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
47
- function seedCommands() {
48
- return {
49
- 'pr-gate': { mode: 'OFF', buildCommand: rules_config_1.DEFAULT_BUILD_COMMAND, gates: [] },
50
- guardHints: { prCreationOrPush: DEFAULT_UPSERT_PR, mergeInProgress: DEFAULT_MERGE_COMPLETE },
51
- };
52
- }
53
- // Required excludePaths block: ONE glob list suppressing hook enforcement per file path. Seeded empty
54
- // (enforce everywhere) — a client adds paths (e.g. "repositories/**") to exempt vendored trees.
55
- //
56
- // Deliberately NOT seeded with webpieces' own `.webpieces/` state dir. That exemption lives in CODE
57
- // (`isWebpiecesStateDir`, consulted by `filterByExcludedPaths` ahead of this list and regardless of it),
58
- // and a glob here would be a second, weaker spelling of it — weaker because `.webpieces/**` compiles to
59
- // an anchored regex that misses the bare directory the predicate matches, and because a config entry
60
- // invites a consumer to delete it and believe the exemption went with it.
61
- // webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design
62
- function seedExcludePaths() {
63
- return [];
64
- }
65
- // Bring an existing `excludePaths` forward to the single-list shape. Already a list → untouched.
66
- // Legacy `{ rules, guards }` → unioned (order preserved, duplicates dropped) and recorded as a change
67
- // so `wp-install-ai-hooks` is the migration path rather than a hand-edit. Anything else → seeded [].
68
- // webpieces-disable no-any-unknown -- `raw` is opaque consumer JSON until narrowed here
69
- // webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design
70
- function migrateExcludePaths(raw, changes) {
71
- if (Array.isArray(raw))
72
- return raw.filter(p => typeof p === 'string');
73
- if (typeof raw === 'object' && raw !== null) {
74
- // webpieces-disable no-any-unknown -- narrowing the opaque legacy block from consumer JSON
75
- const legacy = raw;
76
- const rules = Array.isArray(legacy['rules']) ? legacy['rules'] : [];
77
- const guards = Array.isArray(legacy['guards']) ? legacy['guards'] : [];
78
- const merged = [...new Set([...rules, ...guards].filter(p => typeof p === 'string'))];
79
- changes.push(`migrated excludePaths {rules,guards} -> one list (${merged.length} path(s))`);
80
- return merged;
81
- }
82
- changes.push('added excludePaths ([])');
83
- return seedExcludePaths();
84
- }
85
- /** One retired flat command string and the guardHints field it becomes. Data-only (per CLAUDE.md). */
86
- class GuardHintMove {
87
- retiredKey;
88
- hintKey;
89
- fallback;
90
- constructor(retiredKey, hintKey, fallback) {
91
- this.retiredKey = retiredKey;
92
- this.hintKey = hintKey;
93
- this.fallback = fallback;
94
- }
95
- }
96
- /**
97
- * Bring `commands` forward to the `guardHints` shape, moving the RETIRED flat `upsertPr`/`mergeComplete`
98
- * strings and DELETING them. Deleting is the point: the validator now rejects them, so leaving them behind
99
- * would keep the config failing after a "successful" sync.
100
- *
101
- * The consumer's own value wins over the default — a repo that renamed its gated command keeps that name.
102
- */
103
- // webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design
104
- function migrateGuardHints(commands, changes) {
105
- const hints = (typeof commands['guardHints'] === 'object' && commands['guardHints'] !== null)
106
- ? commands['guardHints'] : {};
107
- const moves = [
108
- new GuardHintMove('upsertPr', 'prCreationOrPush', DEFAULT_UPSERT_PR),
109
- new GuardHintMove('mergeComplete', 'mergeInProgress', DEFAULT_MERGE_COMPLETE),
110
- ];
111
- for (const move of moves) {
112
- const retiredKey = move.retiredKey;
113
- const hintKey = move.hintKey;
114
- const fallback = move.fallback;
115
- const carried = commands[retiredKey];
116
- if (carried !== undefined) {
117
- delete commands[retiredKey];
118
- if (hints[hintKey] === undefined)
119
- hints[hintKey] = carried;
120
- changes.push(`moved retired commands.${retiredKey} -> commands.guardHints.${hintKey}`);
121
- }
122
- if (hints[hintKey] === undefined) {
123
- hints[hintKey] = fallback;
124
- changes.push(`added commands.guardHints.${hintKey}`);
125
- }
126
- }
127
- commands['guardHints'] = hints;
128
- }
129
- /**
130
- * Apply the RETIRED rule/guard retirements in place. These used to be rewritten silently at load time, so
131
- * a consumer's file kept the dead name forever; the loader now rejects it, which makes this the one
132
- * command that can fix the file. Skips a rename when the new name is already configured, so an explicit
133
- * entry is never clobbered by a stale one.
134
- *
135
- * NOT EVERY RETIREMENT IS A RENAME, and treating them all as one produced garbage. `whole-repo-build-guard`
136
- * moved OUT of webpieces.config.json entirely — its `movedTo` is the PROSE destination
137
- * `~/.webpieces/config.json → experimental.whole-repo-build-guard`, not a sibling key — so the rename
138
- * branch below would have created a hookGuards entry literally named that whole sentence, which no
139
- * validator knows and which the next run reports as another unknown rule. `prunable` is the discriminator:
140
- * when the entry says deleting is the whole fix, DELETE it, exactly as `ConfigPruner` does.
141
- */
142
- // webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design
143
- function migrateRetiredRuleNames(section, changes) {
144
- for (const entry of rules_config_1.RETIRED_CONFIG_KEYS) {
145
- if (entry.scope !== rules_config_1.RETIRED_SCOPE_RULE)
146
- continue;
147
- if (!(entry.key in section))
148
- continue;
149
- if (entry.prunable) {
150
- delete section[entry.key];
151
- changes.push(`deleted retired "${entry.key}" (it moved to ${entry.movedTo})`);
152
- continue;
153
- }
154
- mergeIntoDestination(section, entry.key, entry.movedTo, changes);
155
- }
156
- fillRequiredFields(section, changes);
157
- }
158
- /**
159
- * Fold one retired key's entry into its destination, whether the destination exists yet or not.
160
- *
161
- * THIS IS N→1, NOT 1:1, and the difference is the whole reason this helper exists. Four retired keys
162
- * now point at ONE destination (`branch-state-guard`, `pr-lifecycle-guard`). The previous code renamed
163
- * the first key it met and then, finding the destination already present, DELETED each of the other
164
- * three outright — so which guard's settings survived depended on RETIRED_CONFIG_KEYS declaration
165
- * order rather than on the consumer's file, and the survivor carried only that one guard's fields, so
166
- * it was missing required fields of the merged schema. `wp-install-ai-hooks` is the command advertised
167
- * as the migration path; half-migrating every consumer into an invalid config is not an option.
168
- *
169
- * UNION, first writer wins per field. Earlier-declared keys are the more specific ones (only
170
- * feature-branch-guard carries `branchNamingConvention`), and a field already present on the
171
- * destination — because the consumer wrote it, or an earlier key contributed it — is never overwritten.
172
- * Fields the merged schema does not know are dropped by the same pass, since carrying a deleted field
173
- * across (`upsertPrCommand`) would produce a config the validator immediately rejects.
174
- */
175
- // webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design
176
- function mergeIntoDestination(section, key, destination, changes) {
177
- const source = asSection(section[key]);
178
- delete section[key];
179
- const fields = (0, rules_config_1.schemaFieldNames)(destination);
180
- const target = asSection(section[destination]);
181
- const existed = destination in section;
182
- const carried = [];
183
- const dropped = [];
184
- for (const field of Object.keys(source)) {
185
- if (fields !== null && !fields.includes(field)) {
186
- dropped.push(field);
187
- continue;
188
- }
189
- if (field in target)
190
- continue;
191
- target[field] = source[field];
192
- carried.push(field);
193
- }
194
- section[destination] = target;
195
- const verb = existed ? 'merged' : 'renamed';
196
- const droppedNote = dropped.length > 0 ? `; dropped deleted field(s) ${dropped.join(', ')}` : '';
197
- changes.push(`${verb} retired "${key}" -> "${destination}" (carried ${carried.join(', ') || 'nothing new'}${droppedNote})`);
198
- }
199
- /**
200
- * Fill any schema-REQUIRED field a migrated entry ended up without.
201
- *
202
- * A union of four partial entries is not guaranteed to satisfy the destination's schema — the merged
203
- * `branch-state-guard` needs `mode` and both escape hatches, and a consumer whose four old entries
204
- * predate one of them would land short. Seeding the gap from the SAME source the installer and the
205
- * validator use (seedEntryForRule) is what makes the install command a complete instruction
206
- * rather than a first step. Only ever ADDS; a value the consumer stated is never touched.
207
- */
208
- // webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design
209
- function fillRequiredFields(section, changes) {
210
- for (const name of Object.keys(section)) {
211
- if ((0, rules_config_1.schemaFieldNames)(name) === null)
212
- continue;
213
- // A rule ENTRY is a flat bag of scalars, so it is read as Json here rather than through
214
- // asSection (whose values are whole entries). Same object either way; only the view differs.
215
- const entry = asSection(section[name]);
216
- const seed = (0, rules_config_1.seedEntryForRule)(name);
217
- const added = [];
218
- for (const field of Object.keys(seed)) {
219
- if (field in entry)
220
- continue;
221
- entry[field] = seed[field];
222
- added.push(field);
223
- }
224
- if (added.length === 0)
225
- continue;
226
- section[name] = entry;
227
- changes.push(`filled required field(s) on "${name}": ${added.join(', ')}`);
228
- }
229
- }
230
- // Deep-copy the framework's default match-rules (the no-fetch guard) into plain JSON for the config
231
- // file. Round-tripping through JSON turns the MatchRuleConfig instances into plain objects.
232
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
233
- function seedMatchRules() {
234
- return JSON.parse(JSON.stringify(rules_config_1.DEFAULT_MATCH_RULES));
235
- }
236
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
237
- function buildSeedConfig() {
238
- const rules = {};
239
- const hookGuards = {};
240
- for (const name of (0, rules_config_1.allRuleNames)()) {
241
- if ((0, rules_config_1.sectionForRule)(name) === 'hookGuards')
242
- hookGuards[name] = seedRule(name);
243
- else
244
- rules[name] = seedRule(name);
245
- }
246
- return {
247
- rules, hookGuards, commands: seedCommands(), excludePaths: seedExcludePaths(),
248
- // Seed the required match-rules array with the framework's default no-fetch guard. A fresh
249
- // project gets contract-first enforcement out of the box; clients edit it and add more entries.
250
- 'match-rules': seedMatchRules(),
251
- rulesDir: [],
252
- };
253
- }
254
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
255
- function writeConfig(configPath, config) {
256
- fs.writeFileSync(configPath, JSON.stringify(config, null, 4) + '\n');
257
- }
258
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
259
- function readConfig(configPath) {
260
- const raw = fs.readFileSync(configPath, 'utf8');
261
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
262
- try {
263
- return JSON.parse(raw);
264
- }
265
- catch (err) {
266
- const error = (0, to_error_1.toError)(err);
267
- throw new Error(`${CONFIG_FILENAME} has invalid JSON — fix it, then retry: ${error.message}`, { cause: error });
268
- }
269
- }
270
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
271
- function asSection(value) {
272
- return (typeof value === 'object' && value !== null && !Array.isArray(value)) ? value : {};
273
- }
274
- // Migrate an existing config to the rules / hookGuards / commands layout and add any missing rules.
275
- // Returns a human-readable list of what changed (empty = already up to date).
276
- // webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method
277
- function migrate(existing) {
278
- const changes = [];
279
- const rules = asSection(existing['rules']);
280
- const hookGuards = asSection(existing['hookGuards']);
281
- const commands = (typeof existing['commands'] === 'object' && existing['commands'] !== null)
282
- ? existing['commands'] : {};
283
- // Move a deprecated top-level pr-gate block under commands.
284
- if (existing['pr-gate'] !== undefined && commands['pr-gate'] === undefined) {
285
- commands['pr-gate'] = existing['pr-gate'];
286
- changes.push('moved top-level "pr-gate" → commands["pr-gate"]');
287
- }
288
- // Apply retired RENAMES first, so a renamed guard is placed and presence-checked under its new name
289
- // rather than being treated as unknown and re-added alongside its own stale entry.
290
- migrateRetiredRuleNames(rules, changes);
291
- migrateRetiredRuleNames(hookGuards, changes);
292
- // Move guards mistakenly left in rules into hookGuards.
293
- for (const name of Object.keys(rules)) {
294
- if ((0, rules_config_1.isHookGuard)(name)) {
295
- hookGuards[name] = rules[name];
296
- delete rules[name];
297
- changes.push(`moved "${name}" from rules → hookGuards`);
298
- }
299
- }
300
- // Move code rules mistakenly placed in hookGuards back into rules.
301
- for (const name of Object.keys(hookGuards)) {
302
- if (!(0, rules_config_1.isHookGuard)(name) && (0, rules_config_1.allRuleNames)().includes(name)) {
303
- rules[name] = hookGuards[name];
304
- delete hookGuards[name];
305
- changes.push(`moved "${name}" from hookGuards → rules`);
306
- }
307
- }
308
- // Add any missing built-in into its correct section, ENFORCING at its recommended mode (not OFF).
309
- for (const name of (0, rules_config_1.allRuleNames)()) {
310
- const target = (0, rules_config_1.sectionForRule)(name) === 'hookGuards' ? hookGuards : rules;
311
- if (!(name in target)) {
312
- const entry = seedRule(name);
313
- target[name] = entry;
314
- changes.push(`added "${name}" (${String(entry['mode'])}) to ${(0, rules_config_1.sectionForRule)(name)}`);
315
- }
316
- }
317
- // Fill command defaults.
318
- if (commands['pr-gate'] === undefined) {
319
- commands['pr-gate'] = { mode: 'OFF', buildCommand: rules_config_1.DEFAULT_BUILD_COMMAND, gates: [] };
320
- changes.push('added commands["pr-gate"] (OFF)');
321
- }
322
- migrateGuardHints(commands, changes);
323
- // Seed the now-required excludePaths list (empty = enforce everywhere) if the config predates it,
324
- // and MIGRATE the legacy `{ rules: [], guards: [] }` object to the single list by unioning them.
325
- // The union is behaviour-preserving for every config we have seen (both lists set identically), and
326
- // widening is the safe direction anyway: a path either side excluded stays excluded.
327
- const excludePaths = migrateExcludePaths(existing['excludePaths'], changes);
328
- // Seed the now-required match-rules array (with the default no-fetch guard) if the config predates
329
- // it. A client that has already customized it keeps their array untouched.
330
- let matchRules;
331
- if (Array.isArray(existing['match-rules'])) {
332
- matchRules = existing['match-rules'];
333
- }
334
- else {
335
- matchRules = seedMatchRules();
336
- changes.push('added "match-rules" (seeded with the no-fetch guard)');
337
- }
338
- const rulesDir = Array.isArray(existing['rulesDir']) ? existing['rulesDir'] : [];
339
- const config = { rules, hookGuards, commands, excludePaths, 'match-rules': matchRules, rulesDir };
340
- if (typeof existing['extends'] === 'string')
341
- config.extends = existing['extends'];
342
- return { config, changes };
343
- }
344
- // Seed the config when it is missing, migrate it when it is not. ONE behaviour, always — there is no
345
- // "migrate but stop here" mode any more. The flag that used to select it was never NECESSARY (the validator prints
346
- // the exact edit for every error at once, and editing webpieces.config.json is always allowed through the
347
- // guard — the documented primary cure), it REFUSED to act when the config was missing (useless in the one
348
- // case automation would have helped), and it gave deny messages a second competing path when they are
349
- // supposed to end in exactly one action. Readers also mistook it for the shim-repair command, which it
350
- // never was — `wp-upgrade-shim` is that.
351
- // webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
352
- function seedOrSyncConfig(projectRoot) {
353
- const configPath = path.join(projectRoot, CONFIG_FILENAME);
354
- if (!fs.existsSync(configPath)) {
355
- writeConfig(configPath, buildSeedConfig());
356
- console.log(` [ai-hooks] Created ${CONFIG_FILENAME} (rules / hookGuards / commands); each rule seeded at its recommended mode — gradual where supported, so only code you change is enforced.`);
357
- console.log(' Enable the ones you want by changing "mode".');
358
- return;
359
- }
360
- const result = migrate(readConfig(configPath));
361
- if (result.changes.length === 0) {
362
- console.log(` [ai-hooks] ${CONFIG_FILENAME} already uses the rules / hookGuards / commands layout — no changes.`);
363
- return;
364
- }
365
- writeConfig(configPath, result.config);
366
- console.log(` [ai-hooks] Migrated ${CONFIG_FILENAME}:`);
367
- for (const change of result.changes)
368
- console.log(` - ${change}`);
369
- }
370
- //# sourceMappingURL=setup-config.js.map