@webpieces/ai-hook-rules 0.4.839 → 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
@@ -1,87 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.default = handler;
4
- const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
6
- const fs = tslib_1.__importStar(require("fs"));
7
- const rules_config_1 = require("@webpieces/rules-config");
8
- const runner_1 = require("../core/runner");
9
- const types_1 = require("../core/types");
10
- const to_error_1 = require("../core/to-error");
11
- class OpenclawHandlerResult {
12
- status;
13
- reason;
14
- constructor(status, reason) {
15
- this.status = status;
16
- this.reason = reason;
17
- }
18
- }
19
- const TOOL_MAP = {
20
- 'write': 'Write',
21
- 'edit': 'Edit',
22
- };
23
- function mapToolName(openclawName) {
24
- return TOOL_MAP[openclawName] || null;
25
- }
26
- // webpieces-disable no-any-unknown -- openclaw SDK passes opaque tool arguments
27
- function mapToolInput(toolName, args) {
28
- const filePath = typeof args['path'] === 'string' ? args['path'] : null;
29
- if (!filePath)
30
- return null;
31
- if (toolName === 'write') {
32
- const content = typeof args['content'] === 'string' ? args['content'] : '';
33
- return new types_1.NormalizedToolInput(filePath, [new types_1.NormalizedEdit('', content)]);
34
- }
35
- if (toolName === 'edit') {
36
- const oldStr = typeof args['old_string'] === 'string' ? args['old_string'] : '';
37
- const newStr = typeof args['new_string'] === 'string' ? args['new_string'] : '';
38
- return new types_1.NormalizedToolInput(filePath, [new types_1.NormalizedEdit(oldStr, newStr)]);
39
- }
40
- return null;
41
- }
42
- function findWorkspaceRoot(filePath) {
43
- let dir = path.dirname(filePath);
44
- while (true) {
45
- if (fs.existsSync(path.join(dir, rules_config_1.CONFIG_FILENAME)))
46
- return dir;
47
- const parent = path.dirname(dir);
48
- if (parent === dir)
49
- return null;
50
- dir = parent;
51
- }
52
- }
53
- async function handler(event, _context) {
54
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
55
- try {
56
- const toolKind = mapToolName(event.toolName);
57
- if (!toolKind)
58
- return undefined;
59
- const input = mapToolInput(event.toolName, event.arguments);
60
- if (!input)
61
- return undefined;
62
- const wsRoot = findWorkspaceRoot(input.filePath);
63
- if (!wsRoot)
64
- return undefined;
65
- const result = (0, runner_1.run)(toolKind, input, wsRoot);
66
- if (!result)
67
- return new OpenclawHandlerResult('approved');
68
- return new OpenclawHandlerResult('rejected', result.report);
69
- }
70
- catch (err) {
71
- const error = (0, to_error_1.toError)(err);
72
- // An escaped RuleFailError or InformAiError carries an AI-readable message; anything else is
73
- // an unexpected bug. All reject (fail closed).
74
- let msg;
75
- if (error instanceof types_1.RuleFailError) {
76
- msg = (0, rules_config_1.renderRuleFailForAi)(error);
77
- }
78
- else if (error instanceof types_1.InformAiError) {
79
- msg = error.message;
80
- }
81
- else {
82
- msg = `[ai-hooks] openclaw adapter crashed — failing closed: ${error.message}`;
83
- }
84
- return new OpenclawHandlerResult('rejected', msg);
85
- }
86
- }
87
- //# sourceMappingURL=openclaw-plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"openclaw-plugin.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/adapters/openclaw-plugin.ts"],"names":[],"mappings":";;AAiEA,0BAgCC;;AAjGD,mDAA6B;AAC7B,+CAAyB;AAEzB,0DAA+E;AAC/E,2CAAqC;AACrC,yCAA4G;AAC5G,+CAA2C;AAa3C,MAAM,qBAAqB;IACd,MAAM,CAA0B;IAChC,MAAM,CAAqB;IAEpC,YAAY,MAA+B,EAAE,MAAe;QACxD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AAED,MAAM,QAAQ,GAA6B;IACvC,OAAO,EAAE,OAAO;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AAI,KAAK,YAAY,qBAAa,EAAE,CAAC;YACjC,GAAG,GAAG,IAAA,kCAAmB,EAAC,KAAK,CAAC,CAAC;QACrC,CAAC;aAAM,IAAI,KAAK,YAAY,qBAAa,EAAE,CAAC;YACxC,GAAG,GAAG,KAAK,CAAC,OAAO,CAAC;QACxB,CAAC;aAAM,CAAC;YACJ,GAAG,GAAG,yDAAyD,KAAK,CAAC,OAAO,EAAE,CAAC;QACnF,CAAC;QACD,OAAO,IAAI,qBAAqB,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;IACtD,CAAC;AACL,CAAC","sourcesContent":["import * as path from 'path';\nimport * as fs from 'fs';\n\nimport { CONFIG_FILENAME, renderRuleFailForAi } from '@webpieces/rules-config';\nimport { run } from '../core/runner';\nimport { NormalizedToolInput, NormalizedEdit, ToolKind, InformAiError, RuleFailError } from '../core/types';\nimport { toError } from '../core/to-error';\n\ninterface ToolCallEvent {\n toolName: string;\n // webpieces-disable no-any-unknown -- openclaw SDK passes opaque tool arguments\n arguments: Record<string, unknown>;\n}\n\ninterface HookContext {\n // webpieces-disable no-any-unknown -- openclaw SDK context shape is opaque\n [key: string]: unknown;\n}\n\nclass OpenclawHandlerResult {\n readonly status: 'approved' | 'rejected';\n readonly reason: string | undefined;\n\n constructor(status: 'approved' | 'rejected', reason?: string) {\n this.status = status;\n this.reason = reason;\n }\n}\n\nconst TOOL_MAP: Record<string, ToolKind> = {\n 'write': 'Write',\n 'edit': 'Edit',\n};\n\nfunction mapToolName(openclawName: string): ToolKind | null {\n return TOOL_MAP[openclawName] || null;\n}\n\n// webpieces-disable no-any-unknown -- openclaw SDK passes opaque tool arguments\nfunction mapToolInput(toolName: string, args: Record<string, unknown>): NormalizedToolInput | null {\n const filePath = typeof args['path'] === 'string' ? args['path'] as string : null;\n if (!filePath) return null;\n\n if (toolName === 'write') {\n const content = typeof args['content'] === 'string' ? args['content'] as string : '';\n return new NormalizedToolInput(filePath, [new NormalizedEdit('', content)]);\n }\n if (toolName === 'edit') {\n const oldStr = typeof args['old_string'] === 'string' ? args['old_string'] as string : '';\n const newStr = typeof args['new_string'] === 'string' ? args['new_string'] as string : '';\n return new NormalizedToolInput(filePath, [new NormalizedEdit(oldStr, newStr)]);\n }\n return null;\n}\n\nfunction findWorkspaceRoot(filePath: string): string | null {\n let dir = path.dirname(filePath);\n while (true) {\n if (fs.existsSync(path.join(dir, CONFIG_FILENAME))) return dir;\n const parent = path.dirname(dir);\n if (parent === dir) return null;\n dir = parent;\n }\n}\n\nexport default async function handler(\n event: ToolCallEvent,\n _context: HookContext,\n): Promise<OpenclawHandlerResult | undefined> {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const toolKind = mapToolName(event.toolName);\n if (!toolKind) return undefined;\n\n const input = mapToolInput(event.toolName, event.arguments);\n if (!input) return undefined;\n\n const wsRoot = findWorkspaceRoot(input.filePath);\n if (!wsRoot) return undefined;\n\n const result = run(toolKind, input, wsRoot);\n if (!result) return new OpenclawHandlerResult('approved');\n return new OpenclawHandlerResult('rejected', result.report);\n } catch (err: unknown) {\n const error = toError(err);\n // An escaped RuleFailError or InformAiError carries an AI-readable message; anything else is\n // an unexpected bug. All reject (fail closed).\n let msg: string;\n if (error instanceof RuleFailError) {\n msg = renderRuleFailForAi(error);\n } else if (error instanceof InformAiError) {\n msg = error.message;\n } else {\n msg = `[ai-hooks] openclaw adapter crashed — failing closed: ${error.message}`;\n }\n return new OpenclawHandlerResult('rejected', msg);\n }\n}\n"]}
@@ -1,20 +0,0 @@
1
- import { ReviewIdentityStampService } from '@webpieces/repo-workflow-core';
2
- import { AgentHookEvent } from '@webpieces/hook-runtime';
3
- /**
4
- * Tells `pnpm wp-write-review` WHO invoked it (issue #863).
5
- *
6
- * The bin runs inside the Bash call, and a Bash child sees only its environment — which in neither harness
7
- * distinguishes a reviewer subagent from its coordinator (see ReviewIdentityStamp for the detail). This
8
- * hook, by contrast, is handed the harness's own `agent_id` for the very call that is about to run the bin.
9
- * So for every checklist a command submits, it writes one stamp the bin consumes a moment later. The bin
10
- * then REFUSES a stamp that names the coordinating agent — closing the forgery path a Codex coordinator
11
- * took on two merged PRs — and records the subagent's identity in the verdict's provenance.
12
- *
13
- * Called ONLY for a Bash call the guards have already ALLOWED: a denied command never runs the bin, and a
14
- * stamp it left behind would be an identity waiting to be borrowed.
15
- */
16
- export declare class ReviewIdentityStamper {
17
- private readonly stamps;
18
- constructor(stamps?: ReviewIdentityStampService);
19
- stamp(event: AgentHookEvent, command: string, cwd: string): void;
20
- }
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ReviewIdentityStamper = void 0;
4
- const repo_workflow_core_1 = require("@webpieces/repo-workflow-core");
5
- /**
6
- * Tells `pnpm wp-write-review` WHO invoked it (issue #863).
7
- *
8
- * The bin runs inside the Bash call, and a Bash child sees only its environment — which in neither harness
9
- * distinguishes a reviewer subagent from its coordinator (see ReviewIdentityStamp for the detail). This
10
- * hook, by contrast, is handed the harness's own `agent_id` for the very call that is about to run the bin.
11
- * So for every checklist a command submits, it writes one stamp the bin consumes a moment later. The bin
12
- * then REFUSES a stamp that names the coordinating agent — closing the forgery path a Codex coordinator
13
- * took on two merged PRs — and records the subagent's identity in the verdict's provenance.
14
- *
15
- * Called ONLY for a Bash call the guards have already ALLOWED: a denied command never runs the bin, and a
16
- * stamp it left behind would be an identity waiting to be borrowed.
17
- */
18
- class ReviewIdentityStamper {
19
- stamps;
20
- constructor(stamps = repo_workflow_core_1.reviewIdentityStamps) {
21
- this.stamps = stamps;
22
- }
23
- stamp(event, command, cwd) {
24
- const checklists = this.stamps.invokedChecklists(command);
25
- if (checklists.length === 0)
26
- return;
27
- const now = new Date().toISOString();
28
- for (const checklistId of checklists) {
29
- this.stamps.write(cwd, new repo_workflow_core_1.ReviewIdentityStamp(checklistId, event.aiType, event.sessionId, event.agentId, event.agentType, cwd, now));
30
- }
31
- }
32
- }
33
- exports.ReviewIdentityStamper = ReviewIdentityStamper;
34
- //# sourceMappingURL=review-identity-stamper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"review-identity-stamper.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/adapters/review-identity-stamper.ts"],"names":[],"mappings":";;;AAAA,sEAAsH;AAItH;;;;;;;;;;;;GAYG;AACH,MAAa,qBAAqB;IACD;IAA7B,YAA6B,SAAqC,yCAAoB;QAAzD,WAAM,GAAN,MAAM,CAAmD;IAAG,CAAC;IAE1F,KAAK,CAAC,KAAqB,EAAE,OAAe,EAAE,GAAW;QACrD,MAAM,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,iBAAiB,CAAC,OAAO,CAAC,CAAC;QAC1D,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO;QACpC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC;QACrC,KAAK,MAAM,WAAW,IAAI,UAAU,EAAE,CAAC;YACnC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,wCAAmB,CAC1C,WAAW,EAAE,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;QAC/F,CAAC;IACL,CAAC;CACJ;AAZD,sDAYC","sourcesContent":["import { ReviewIdentityStamp, ReviewIdentityStampService, reviewIdentityStamps } from '@webpieces/repo-workflow-core';\n\nimport { AgentHookEvent } from '@webpieces/hook-runtime';\n\n/**\n * Tells `pnpm wp-write-review` WHO invoked it (issue #863).\n *\n * The bin runs inside the Bash call, and a Bash child sees only its environment — which in neither harness\n * distinguishes a reviewer subagent from its coordinator (see ReviewIdentityStamp for the detail). This\n * hook, by contrast, is handed the harness's own `agent_id` for the very call that is about to run the bin.\n * So for every checklist a command submits, it writes one stamp the bin consumes a moment later. The bin\n * then REFUSES a stamp that names the coordinating agent — closing the forgery path a Codex coordinator\n * took on two merged PRs — and records the subagent's identity in the verdict's provenance.\n *\n * Called ONLY for a Bash call the guards have already ALLOWED: a denied command never runs the bin, and a\n * stamp it left behind would be an identity waiting to be borrowed.\n */\nexport class ReviewIdentityStamper {\n constructor(private readonly stamps: ReviewIdentityStampService = reviewIdentityStamps) {}\n\n stamp(event: AgentHookEvent, command: string, cwd: string): void {\n const checklists = this.stamps.invokedChecklists(command);\n if (checklists.length === 0) return;\n const now = new Date().toISOString();\n for (const checklistId of checklists) {\n this.stamps.write(cwd, new ReviewIdentityStamp(\n checklistId, event.aiType, event.sessionId, event.agentId, event.agentType, cwd, now));\n }\n }\n}\n"]}
@@ -1,105 +0,0 @@
1
- /**
2
- * CODEX HOOK TRUST — read it, report it, NEVER write it.
3
- *
4
- * ─── What Codex actually does ─────────────────────────────────────────────────────────────────────
5
- * Codex trusts a hook entry TOFU. On first sight of a new or changed entry it PROMPTS
6
- * (`Hooks need review / 1 hook is new or changed`) and, if the human accepts, records a hash in
7
- * `~/.codex/config.toml`:
8
- *
9
- * [hooks.state."<abs path to .codex/hooks.json>:pre_tool_use:<group>:<index>"]
10
- * trusted_hash = "sha256:…"
11
- *
12
- * ─── Why this only ever REPORTS ───────────────────────────────────────────────────────────────────
13
- * The hash is NOT reproducible from outside Codex. Sixteen encodings were tried against a hooks.json we
14
- * wrote ourselves and none of them produced the recorded value. So an installer that tried to write one
15
- * would be guessing at a security decision on a human's behalf, and would either be ignored or — worse —
16
- * appear to succeed. Forging it is not on the table even if the encoding were known: the prompt IS the
17
- * mechanism, and the whole point of TOFU is that a person saw the command once.
18
- *
19
- * The consequence the installer must therefore SAY OUT LOUD: the prompt's third option is
20
- * `Continue without trusting (hooks won't run)`. That is one keystroke to a fully unguarded session,
21
- * with no later warning of any kind. Install-time verification cannot see that choice — it happens
22
- * afterwards, in another process — so this check reports the trust state it CAN read, names the file it
23
- * read it from, and stops there.
24
- *
25
- * Declining the prompt is a HUMAN's decision about their own machine, and it is deliberately left
26
- * standing. Tooling that tried to detect and refuse it afterwards would be voiding a setting a person
27
- * chose on purpose, and it has nothing to catch besides: the guards constrain the AGENT, while the
28
- * prompt is answered by the HUMAN, who the agent cannot impersonate. So there is no second mechanism
29
- * downstream of this one — this report is the whole of what webpieces knows about Codex trust.
30
- */
31
- /** What one repo's Codex trust looks like right now. Data-only → a class, per CLAUDE.md. */
32
- export declare class CodexTrustStatus {
33
- /** `~/.codex/config.toml`, named even when it does not exist so the report can point at it. */
34
- readonly configPath: string;
35
- readonly configExists: boolean;
36
- /** `[projects."<root>"] trust_level = "trusted"`. */
37
- readonly projectTrusted: boolean;
38
- /** The repo's `.codex/hooks.json`, absolute — the key every `hooks.state` entry is prefixed by. */
39
- readonly hooksPath: string;
40
- /** How many webpieces-managed PreToolUse entries that file registers. 0 ⇒ Codex is not armed. */
41
- readonly registeredEntries: number;
42
- /** How many of them `~/.codex/config.toml` records a `trusted_hash` for. */
43
- readonly trustedEntries: number;
44
- constructor(
45
- /** `~/.codex/config.toml`, named even when it does not exist so the report can point at it. */
46
- configPath: string, configExists: boolean,
47
- /** `[projects."<root>"] trust_level = "trusted"`. */
48
- projectTrusted: boolean,
49
- /** The repo's `.codex/hooks.json`, absolute — the key every `hooks.state` entry is prefixed by. */
50
- hooksPath: string,
51
- /** How many webpieces-managed PreToolUse entries that file registers. 0 ⇒ Codex is not armed. */
52
- registeredEntries: number,
53
- /** How many of them `~/.codex/config.toml` records a `trusted_hash` for. */
54
- trustedEntries: number);
55
- /** True when Codex is armed here AND every entry it would run is trusted. */
56
- fullyTrusted(): boolean;
57
- /** True when there is nothing to say — this repo has not armed Codex at all. */
58
- notArmed(): boolean;
59
- /**
60
- * The report, as lines. It states what IS, then the one action that changes it — and the action is
61
- * always the human's, because nothing here can be repaired by a tool.
62
- */
63
- lines(): readonly string[];
64
- }
65
- /**
66
- * Reads Codex's trust state. Never writes, never throws — an unreadable or absent config reports as
67
- * "not trusted", which is the true and safe answer.
68
- */
69
- export declare class CodexTrustProbe {
70
- /** `~/.codex/config.toml`. `homeDir` is injectable so a unit test never reads the real one. */
71
- configPath(homeDir?: string): string;
72
- read(projectRoot: string, homeDir?: string): CodexTrustStatus;
73
- /**
74
- * How many webpieces-managed PreToolUse commands `.codex/hooks.json` registers.
75
- *
76
- * It counts what WE own, not every hook in the file: a consumer's own unrelated hook is none of this
77
- * check's business, and counting it would make the report say "1 of 3 trusted" about hooks webpieces
78
- * neither wrote nor can advise on.
79
- */
80
- private registeredEntryCount;
81
- private readOrEmpty;
82
- /**
83
- * `[projects."<root>"]` carrying `trust_level = "trusted"`.
84
- *
85
- * A LINE SCAN, not a TOML parser, and deliberately: this package must load on a tree too broken to
86
- * build a DI container, so it takes no dependency it does not need, and the two shapes it reads are
87
- * both written by Codex itself in one fixed form. It over-reports "not trusted" for anything it
88
- * cannot recognise, which is the safe direction — the consequence is one advisory line too many,
89
- * never a session reported as guarded when it is not.
90
- */
91
- private projectTrusted;
92
- /**
93
- * How many `hooks.state."<hooksPath>:pre_tool_use:<group>:<index>"` sections carry a `trusted_hash`.
94
- *
95
- * The count is compared against the number of entries the file registers rather than matched
96
- * one-for-one to a specific group/index: the group and index are Codex's own numbering of a file it
97
- * re-reads on every launch, and an installer that assumed a numbering would report a false alarm the
98
- * first time Codex renumbered.
99
- */
100
- private trustedEntryCount;
101
- /** The body lines of one TOML section, or [] when the file carries no such header. */
102
- private sectionBody;
103
- /** The `<name>` of a `[<name>]` header line, or null for anything else. */
104
- private headerOf;
105
- }
@@ -1,205 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CodexTrustProbe = exports.CodexTrustStatus = void 0;
4
- const tslib_1 = require("tslib");
5
- const fs = tslib_1.__importStar(require("fs"));
6
- const path = tslib_1.__importStar(require("path"));
7
- const os_1 = require("os");
8
- const to_error_1 = require("../core/to-error");
9
- const hook_registration_1 = require("./hook-registration");
10
- /**
11
- * CODEX HOOK TRUST — read it, report it, NEVER write it.
12
- *
13
- * ─── What Codex actually does ─────────────────────────────────────────────────────────────────────
14
- * Codex trusts a hook entry TOFU. On first sight of a new or changed entry it PROMPTS
15
- * (`Hooks need review / 1 hook is new or changed`) and, if the human accepts, records a hash in
16
- * `~/.codex/config.toml`:
17
- *
18
- * [hooks.state."<abs path to .codex/hooks.json>:pre_tool_use:<group>:<index>"]
19
- * trusted_hash = "sha256:…"
20
- *
21
- * ─── Why this only ever REPORTS ───────────────────────────────────────────────────────────────────
22
- * The hash is NOT reproducible from outside Codex. Sixteen encodings were tried against a hooks.json we
23
- * wrote ourselves and none of them produced the recorded value. So an installer that tried to write one
24
- * would be guessing at a security decision on a human's behalf, and would either be ignored or — worse —
25
- * appear to succeed. Forging it is not on the table even if the encoding were known: the prompt IS the
26
- * mechanism, and the whole point of TOFU is that a person saw the command once.
27
- *
28
- * The consequence the installer must therefore SAY OUT LOUD: the prompt's third option is
29
- * `Continue without trusting (hooks won't run)`. That is one keystroke to a fully unguarded session,
30
- * with no later warning of any kind. Install-time verification cannot see that choice — it happens
31
- * afterwards, in another process — so this check reports the trust state it CAN read, names the file it
32
- * read it from, and stops there.
33
- *
34
- * Declining the prompt is a HUMAN's decision about their own machine, and it is deliberately left
35
- * standing. Tooling that tried to detect and refuse it afterwards would be voiding a setting a person
36
- * chose on purpose, and it has nothing to catch besides: the guards constrain the AGENT, while the
37
- * prompt is answered by the HUMAN, who the agent cannot impersonate. So there is no second mechanism
38
- * downstream of this one — this report is the whole of what webpieces knows about Codex trust.
39
- */
40
- /** What one repo's Codex trust looks like right now. Data-only → a class, per CLAUDE.md. */
41
- class CodexTrustStatus {
42
- configPath;
43
- configExists;
44
- projectTrusted;
45
- hooksPath;
46
- registeredEntries;
47
- trustedEntries;
48
- // eslint-disable-next-line @typescript-eslint/max-params
49
- constructor(
50
- /** `~/.codex/config.toml`, named even when it does not exist so the report can point at it. */
51
- configPath, configExists,
52
- /** `[projects."<root>"] trust_level = "trusted"`. */
53
- projectTrusted,
54
- /** The repo's `.codex/hooks.json`, absolute — the key every `hooks.state` entry is prefixed by. */
55
- hooksPath,
56
- /** How many webpieces-managed PreToolUse entries that file registers. 0 ⇒ Codex is not armed. */
57
- registeredEntries,
58
- /** How many of them `~/.codex/config.toml` records a `trusted_hash` for. */
59
- trustedEntries) {
60
- this.configPath = configPath;
61
- this.configExists = configExists;
62
- this.projectTrusted = projectTrusted;
63
- this.hooksPath = hooksPath;
64
- this.registeredEntries = registeredEntries;
65
- this.trustedEntries = trustedEntries;
66
- }
67
- /** True when Codex is armed here AND every entry it would run is trusted. */
68
- fullyTrusted() {
69
- return this.registeredEntries > 0 && this.trustedEntries >= this.registeredEntries && this.projectTrusted;
70
- }
71
- /** True when there is nothing to say — this repo has not armed Codex at all. */
72
- notArmed() {
73
- return this.registeredEntries === 0;
74
- }
75
- /**
76
- * The report, as lines. It states what IS, then the one action that changes it — and the action is
77
- * always the human's, because nothing here can be repaired by a tool.
78
- */
79
- lines() {
80
- if (this.notArmed())
81
- return [];
82
- if (this.fullyTrusted()) {
83
- return [` ✅ Codex trusts all ${String(this.registeredEntries)} webpieces hook(s) in ${this.hooksPath}`];
84
- }
85
- const out = [];
86
- out.push(` ⚠️ Codex has NOT yet trusted the webpieces hooks in ${this.hooksPath}`);
87
- if (!this.configExists) {
88
- out.push(` ${this.configPath} does not exist yet — Codex has never run for this user.`);
89
- }
90
- else if (!this.projectTrusted) {
91
- out.push(' this project is not marked trusted in ~/.codex/config.toml.');
92
- }
93
- if (this.trustedEntries < this.registeredEntries) {
94
- out.push(` ${String(this.trustedEntries)} of ${String(this.registeredEntries)} hook entries carry a trusted_hash.`);
95
- }
96
- out.push(' Fix: run `codex` in this repo and choose "Trust all" when it asks about hooks.');
97
- out.push(' Its third option ("Continue without trusting") leaves the session UNGUARDED for its');
98
- out.push(' whole life, and nothing later in the run reports that — this message is the only notice.');
99
- return out;
100
- }
101
- }
102
- exports.CodexTrustStatus = CodexTrustStatus;
103
- /**
104
- * Reads Codex's trust state. Never writes, never throws — an unreadable or absent config reports as
105
- * "not trusted", which is the true and safe answer.
106
- */
107
- class CodexTrustProbe {
108
- /** `~/.codex/config.toml`. `homeDir` is injectable so a unit test never reads the real one. */
109
- configPath(homeDir = (0, os_1.homedir)()) {
110
- return path.join(homeDir, '.codex', 'config.toml');
111
- }
112
- read(projectRoot, homeDir = (0, os_1.homedir)()) {
113
- const configPath = this.configPath(homeDir);
114
- const hooksPath = path.join(projectRoot, ...hook_registration_1.CODEX_REGISTRATION.settingsFiles[0].split('/'));
115
- const registered = this.registeredEntryCount(hooksPath);
116
- const raw = this.readOrEmpty(configPath);
117
- return new CodexTrustStatus(configPath, raw !== null, this.projectTrusted(raw ?? '', projectRoot), hooksPath, registered, this.trustedEntryCount(raw ?? '', hooksPath));
118
- }
119
- /**
120
- * How many webpieces-managed PreToolUse commands `.codex/hooks.json` registers.
121
- *
122
- * It counts what WE own, not every hook in the file: a consumer's own unrelated hook is none of this
123
- * check's business, and counting it would make the report say "1 of 3 trusted" about hooks webpieces
124
- * neither wrote nor can advise on.
125
- */
126
- registeredEntryCount(hooksPath) {
127
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
128
- try {
129
- if (!fs.existsSync(hooksPath))
130
- return 0;
131
- const entries = (0, hook_registration_1.readSettings)(hooksPath).hooks?.PreToolUse ?? [];
132
- return entries.reduce((total, entry) => total + entry.hooks.filter((h) => (0, hook_registration_1.isManagedCommand)(h.command)).length, 0);
133
- }
134
- catch (err) {
135
- const error = (0, to_error_1.toError)(err);
136
- void error; // an unreadable/invalid hooks.json is "not armed"; the drift check is what reports that
137
- return 0;
138
- }
139
- }
140
- readOrEmpty(configPath) {
141
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
142
- try {
143
- return fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf8') : null;
144
- }
145
- catch (err) {
146
- const error = (0, to_error_1.toError)(err);
147
- void error; // unreadable → treated as absent, which reports as "not trusted"
148
- return null;
149
- }
150
- }
151
- /**
152
- * `[projects."<root>"]` carrying `trust_level = "trusted"`.
153
- *
154
- * A LINE SCAN, not a TOML parser, and deliberately: this package must load on a tree too broken to
155
- * build a DI container, so it takes no dependency it does not need, and the two shapes it reads are
156
- * both written by Codex itself in one fixed form. It over-reports "not trusted" for anything it
157
- * cannot recognise, which is the safe direction — the consequence is one advisory line too many,
158
- * never a session reported as guarded when it is not.
159
- */
160
- projectTrusted(raw, projectRoot) {
161
- return this.sectionBody(raw, `projects."${projectRoot}"`)
162
- .some((line) => /^\s*trust_level\s*=\s*"trusted"\s*$/.test(line));
163
- }
164
- /**
165
- * How many `hooks.state."<hooksPath>:pre_tool_use:<group>:<index>"` sections carry a `trusted_hash`.
166
- *
167
- * The count is compared against the number of entries the file registers rather than matched
168
- * one-for-one to a specific group/index: the group and index are Codex's own numbering of a file it
169
- * re-reads on every launch, and an installer that assumed a numbering would report a false alarm the
170
- * first time Codex renumbered.
171
- */
172
- trustedEntryCount(raw, hooksPath) {
173
- const prefix = `hooks.state."${hooksPath}:pre_tool_use:`;
174
- let trusted = 0;
175
- let inEntry = false;
176
- for (const line of raw.split('\n')) {
177
- const header = this.headerOf(line);
178
- if (header !== null)
179
- inEntry = header.startsWith(prefix);
180
- else if (inEntry && /^\s*trusted_hash\s*=\s*"/.test(line))
181
- trusted += 1;
182
- }
183
- return trusted;
184
- }
185
- /** The body lines of one TOML section, or [] when the file carries no such header. */
186
- sectionBody(raw, wanted) {
187
- const body = [];
188
- let inside = false;
189
- for (const line of raw.split('\n')) {
190
- const header = this.headerOf(line);
191
- if (header !== null)
192
- inside = header === wanted;
193
- else if (inside)
194
- body.push(line);
195
- }
196
- return body;
197
- }
198
- /** The `<name>` of a `[<name>]` header line, or null for anything else. */
199
- headerOf(line) {
200
- const match = /^\s*\[([^\]]+)\]\s*$/.exec(line);
201
- return match === null ? null : match[1];
202
- }
203
- }
204
- exports.CodexTrustProbe = CodexTrustProbe;
205
- //# sourceMappingURL=codex-trust.js.map
@@ -1 +0,0 @@
1
- {"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C,QAAQ,CAAC,IAAI,CAAC,CAAC;YACnC,IAAI,MAAM,KAAK,IAAI;gBAAE,MAAM,GAAG,MAAM,KAAK,MAAM,CAAC;iBAC3C,IAAI,MAAM;gBAAE,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACrC,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,2EAA2E;IACnE,QAAQ,CAAC,IAAY;QACzB,MAAM,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAChD,OAAO,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC5C,CAAC;CACJ;AAvGD,0CAuGC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\nimport { homedir } from 'os';\n\nimport { toError } from '../core/to-error';\nimport { CODEX_REGISTRATION, isManagedCommand, readSettings } from './hook-registration';\nimport type { HookCommand, HookEntry } from './settings-shape';\n\n/**\n * CODEX HOOK TRUST — read it, report it, NEVER write it.\n *\n * ─── What Codex actually does ─────────────────────────────────────────────────────────────────────\n * Codex trusts a hook entry TOFU. On first sight of a new or changed entry it PROMPTS\n * (`Hooks need review / 1 hook is new or changed`) and, if the human accepts, records a hash in\n * `~/.codex/config.toml`:\n *\n * [hooks.state.\"<abs path to .codex/hooks.json>:pre_tool_use:<group>:<index>\"]\n * trusted_hash = \"sha256:…\"\n *\n * ─── Why this only ever REPORTS ───────────────────────────────────────────────────────────────────\n * The hash is NOT reproducible from outside Codex. Sixteen encodings were tried against a hooks.json we\n * wrote ourselves and none of them produced the recorded value. So an installer that tried to write one\n * would be guessing at a security decision on a human's behalf, and would either be ignored or — worse —\n * appear to succeed. Forging it is not on the table even if the encoding were known: the prompt IS the\n * mechanism, and the whole point of TOFU is that a person saw the command once.\n *\n * The consequence the installer must therefore SAY OUT LOUD: the prompt's third option is\n * `Continue without trusting (hooks won't run)`. That is one keystroke to a fully unguarded session,\n * with no later warning of any kind. Install-time verification cannot see that choice — it happens\n * afterwards, in another process — so this check reports the trust state it CAN read, names the file it\n * read it from, and stops there.\n *\n * Declining the prompt is a HUMAN's decision about their own machine, and it is deliberately left\n * standing. Tooling that tried to detect and refuse it afterwards would be voiding a setting a person\n * chose on purpose, and it has nothing to catch besides: the guards constrain the AGENT, while the\n * prompt is answered by the HUMAN, who the agent cannot impersonate. So there is no second mechanism\n * downstream of this one — this report is the whole of what webpieces knows about Codex trust.\n */\n\n/** What one repo's Codex trust looks like right now. Data-only → a class, per CLAUDE.md. */\nexport class CodexTrustStatus {\n // eslint-disable-next-line @typescript-eslint/max-params\n constructor(\n /** `~/.codex/config.toml`, named even when it does not exist so the report can point at it. */\n readonly configPath: string,\n readonly configExists: boolean,\n /** `[projects.\"<root>\"] trust_level = \"trusted\"`. */\n readonly projectTrusted: boolean,\n /** The repo's `.codex/hooks.json`, absolute — the key every `hooks.state` entry is prefixed by. */\n readonly hooksPath: string,\n /** How many webpieces-managed PreToolUse entries that file registers. 0 ⇒ Codex is not armed. */\n readonly registeredEntries: number,\n /** How many of them `~/.codex/config.toml` records a `trusted_hash` for. */\n readonly trustedEntries: number,\n ) {}\n\n /** True when Codex is armed here AND every entry it would run is trusted. */\n fullyTrusted(): boolean {\n return this.registeredEntries > 0 && this.trustedEntries >= this.registeredEntries && this.projectTrusted;\n }\n\n /** True when there is nothing to say — this repo has not armed Codex at all. */\n notArmed(): boolean {\n return this.registeredEntries === 0;\n }\n\n /**\n * The report, as lines. It states what IS, then the one action that changes it — and the action is\n * always the human's, because nothing here can be repaired by a tool.\n */\n lines(): readonly string[] {\n if (this.notArmed()) return [];\n if (this.fullyTrusted()) {\n return [` ✅ Codex trusts all ${String(this.registeredEntries)} webpieces hook(s) in ${this.hooksPath}`];\n }\n const out: string[] = [];\n out.push(` ⚠️ Codex has NOT yet trusted the webpieces hooks in ${this.hooksPath}`);\n if (!this.configExists) {\n out.push(` ${this.configPath} does not exist yet — Codex has never run for this user.`);\n } else if (!this.projectTrusted) {\n out.push(' this project is not marked trusted in ~/.codex/config.toml.');\n }\n if (this.trustedEntries < this.registeredEntries) {\n out.push(` ${String(this.trustedEntries)} of ${String(this.registeredEntries)} hook entries carry a trusted_hash.`);\n }\n out.push(' Fix: run `codex` in this repo and choose \"Trust all\" when it asks about hooks.');\n out.push(' Its third option (\"Continue without trusting\") leaves the session UNGUARDED for its');\n out.push(' whole life, and nothing later in the run reports that — this message is the only notice.');\n return out;\n }\n}\n\n/**\n * Reads Codex's trust state. Never writes, never throws — an unreadable or absent config reports as\n * \"not trusted\", which is the true and safe answer.\n */\nexport class CodexTrustProbe {\n /** `~/.codex/config.toml`. `homeDir` is injectable so a unit test never reads the real one. */\n configPath(homeDir: string = homedir()): string {\n return path.join(homeDir, '.codex', 'config.toml');\n }\n\n read(projectRoot: string, homeDir: string = homedir()): CodexTrustStatus {\n const configPath = this.configPath(homeDir);\n const hooksPath = path.join(projectRoot, ...CODEX_REGISTRATION.settingsFiles[0].split('/'));\n const registered = this.registeredEntryCount(hooksPath);\n const raw = this.readOrEmpty(configPath);\n return new CodexTrustStatus(\n configPath, raw !== null, this.projectTrusted(raw ?? '', projectRoot),\n hooksPath, registered, this.trustedEntryCount(raw ?? '', hooksPath),\n );\n }\n\n /**\n * How many webpieces-managed PreToolUse commands `.codex/hooks.json` registers.\n *\n * It counts what WE own, not every hook in the file: a consumer's own unrelated hook is none of this\n * check's business, and counting it would make the report say \"1 of 3 trusted\" about hooks webpieces\n * neither wrote nor can advise on.\n */\n private registeredEntryCount(hooksPath: string): number {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n if (!fs.existsSync(hooksPath)) return 0;\n const entries: readonly HookEntry[] = readSettings(hooksPath).hooks?.PreToolUse ?? [];\n return entries.reduce(\n (total: number, entry: HookEntry): number =>\n total + entry.hooks.filter((h: HookCommand): boolean => isManagedCommand(h.command)).length,\n 0,\n );\n } catch (err: unknown) {\n const error = toError(err);\n void error; // an unreadable/invalid hooks.json is \"not armed\"; the drift check is what reports that\n return 0;\n }\n }\n\n private readOrEmpty(configPath: string): string | null {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return fs.existsSync(configPath) ? fs.readFileSync(configPath, 'utf8') : null;\n } catch (err: unknown) {\n const error = toError(err);\n void error; // unreadable → treated as absent, which reports as \"not trusted\"\n return null;\n }\n }\n\n /**\n * `[projects.\"<root>\"]` carrying `trust_level = \"trusted\"`.\n *\n * A LINE SCAN, not a TOML parser, and deliberately: this package must load on a tree too broken to\n * build a DI container, so it takes no dependency it does not need, and the two shapes it reads are\n * both written by Codex itself in one fixed form. It over-reports \"not trusted\" for anything it\n * cannot recognise, which is the safe direction — the consequence is one advisory line too many,\n * never a session reported as guarded when it is not.\n */\n private projectTrusted(raw: string, projectRoot: string): boolean {\n return this.sectionBody(raw, `projects.\"${projectRoot}\"`)\n .some((line: string): boolean => /^\\s*trust_level\\s*=\\s*\"trusted\"\\s*$/.test(line));\n }\n\n /**\n * How many `hooks.state.\"<hooksPath>:pre_tool_use:<group>:<index>\"` sections carry a `trusted_hash`.\n *\n * The count is compared against the number of entries the file registers rather than matched\n * one-for-one to a specific group/index: the group and index are Codex's own numbering of a file it\n * re-reads on every launch, and an installer that assumed a numbering would report a false alarm the\n * first time Codex renumbered.\n */\n private trustedEntryCount(raw: string, hooksPath: string): number {\n const prefix = `hooks.state.\"${hooksPath}:pre_tool_use:`;\n let trusted = 0;\n let inEntry = false;\n for (const line of raw.split('\\n')) {\n const header = this.headerOf(line);\n if (header !== null) inEntry = header.startsWith(prefix);\n else if (inEntry && /^\\s*trusted_hash\\s*=\\s*\"/.test(line)) trusted += 1;\n }\n return trusted;\n }\n\n /** The body lines of one TOML section, or [] when the file carries no such header. */\n private sectionBody(raw: string, wanted: string): readonly string[] {\n const body: string[] = [];\n let inside = false;\n for (const line of raw.split('\\n')) {\n const header = this.headerOf(line);\n if (header !== null) inside = header === wanted;\n else if (inside) body.push(line);\n }\n return body;\n }\n\n /** The `<name>` of a `[<name>]` header line, or null for anything else. */\n private headerOf(line: string): string | null {\n const match = /^\\s*\\[([^\\]]+)\\]\\s*$/.exec(line);\n return match === null ? null : match[1];\n }\n}\n"]}
@@ -1 +0,0 @@
1
- export declare function runDevHookInstall(): Promise<void>;
@@ -1,82 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runDevHookInstall = runDevHookInstall;
4
- const fs_1 = require("fs");
5
- const os_1 = require("os");
6
- const path_1 = require("path");
7
- const rules_config_1 = require("@webpieces/rules-config");
8
- function wireLocalRulesConfig(cwd, distRulesConfigPath) {
9
- // Place the symlink in dist/packages/tooling/node_modules/ — one level above
10
- // the ai-hook-rules package output but still below the workspace root node_modules.
11
- // Node's require() resolution walks up from the requiring file and finds this
12
- // node_modules entry before reaching the workspace root's stale published package.
13
- // This directory is NOT wiped by any individual package build (each build only
14
- // cleans its own output subfolder), so it survives a full workspace build too.
15
- const overrideDir = (0, path_1.join)(cwd, 'dist', 'packages', 'tooling', 'node_modules', '@webpieces');
16
- const overrideLink = (0, path_1.join)(overrideDir, 'rules-config');
17
- (0, fs_1.mkdirSync)(overrideDir, { recursive: true });
18
- if ((0, fs_1.existsSync)(overrideLink)) {
19
- (0, fs_1.rmSync)(overrideLink, { recursive: true });
20
- }
21
- (0, fs_1.symlinkSync)(distRulesConfigPath, overrideLink);
22
- }
23
- // NOTE: this is a dev-only tool, no longer a `wp-*` bin. Run it directly with node against the local
24
- // build: `node dist/packages/tooling/ai-hook-rules/src/bin/dev-hook-install.js`.
25
- async function runDevHookInstall() {
26
- const cwd = process.cwd();
27
- const adaptersDir = (0, path_1.join)(cwd, 'dist', 'packages', 'tooling', 'ai-hook-rules', 'src', 'adapters');
28
- // Mirror production .claude/settings.json: two independent PreToolUse hooks, one per category.
29
- const rulesHookPath = (0, path_1.join)(adaptersDir, 'rules-hook.js');
30
- const guardsHookPath = (0, path_1.join)(adaptersDir, 'guards-hook.js');
31
- if (!(0, fs_1.existsSync)(rulesHookPath) || !(0, fs_1.existsSync)(guardsHookPath)) {
32
- console.error(`[dev-hook-install] Local build not found at: ${adaptersDir}`);
33
- console.error(' Run `pnpm nx run ai-hook-rules:build` first.');
34
- throw new rules_config_1.CliExitError(1, '');
35
- }
36
- const distRulesConfigPath = (0, path_1.join)(cwd, 'dist', 'packages', 'tooling', 'rules-config');
37
- if (!(0, fs_1.existsSync)(distRulesConfigPath)) {
38
- console.error(`[dev-hook-install] Local rules-config build not found at: ${distRulesConfigPath}`);
39
- console.error(' Run `pnpm nx run rules-config:build` first.');
40
- throw new rules_config_1.CliExitError(1, '');
41
- }
42
- const homeDir = (0, os_1.homedir)();
43
- const webpiecesDir = (0, path_1.join)(homeDir, '.webpieces');
44
- const backupPath = (0, path_1.join)(webpiecesDir, 'dev-hook-backup.json');
45
- const claudeSettingsPath = (0, path_1.join)(homeDir, '.claude', 'settings.json');
46
- if ((0, fs_1.existsSync)(backupPath)) {
47
- console.error('[dev-hook-install] Dev hook is already installed (backup file exists).');
48
- console.error(' Run `node dist/packages/tooling/ai-hook-rules/src/bin/dev-hook-uninstall.js` first to remove the current dev hook.');
49
- throw new rules_config_1.CliExitError(1, '');
50
- }
51
- wireLocalRulesConfig(cwd, distRulesConfigPath);
52
- let settings = {};
53
- if ((0, fs_1.existsSync)(claudeSettingsPath)) {
54
- settings = JSON.parse((0, fs_1.readFileSync)(claudeSettingsPath, 'utf8'));
55
- }
56
- // Save whatever hooks exist now (may be undefined/null) so uninstall can restore them
57
- const backup = { previousHooks: settings.hooks ?? null };
58
- if (!(0, fs_1.existsSync)(webpiecesDir)) {
59
- (0, fs_1.mkdirSync)(webpiecesDir, { recursive: true });
60
- }
61
- (0, fs_1.writeFileSync)(backupPath, JSON.stringify(backup, null, 4) + '\n');
62
- // Mirror production wiring: rules hook on file tools, guards hook on file + Bash tools.
63
- settings.hooks = {
64
- PreToolUse: [
65
- {
66
- matcher: 'Write|Edit|MultiEdit',
67
- hooks: [{ type: 'command', command: `node ${rulesHookPath}` }],
68
- },
69
- {
70
- matcher: 'Write|Edit|MultiEdit|Bash|Read',
71
- hooks: [{ type: 'command', command: `node ${guardsHookPath}` }],
72
- },
73
- ],
74
- };
75
- (0, fs_1.mkdirSync)((0, path_1.dirname)(claudeSettingsPath), { recursive: true });
76
- (0, fs_1.writeFileSync)(claudeSettingsPath, JSON.stringify(settings, null, 4) + '\n');
77
- console.log(` Dev hooks installed → node ${rulesHookPath} (rules), node ${guardsHookPath} (guards)`);
78
- console.log(' Run `node dist/packages/tooling/ai-hook-rules/src/bin/dev-hook-uninstall.js` when done testing.');
79
- }
80
- if (require.main === module)
81
- (0, rules_config_1.runMain)(runDevHookInstall);
82
- //# sourceMappingURL=dev-hook-install.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dev-hook-install.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/dev-hook-install.ts"],"names":[],"mappings":";;AAwCA,8CAgEC;AAxGD,2BAA6F;AAC7F,2BAA6B;AAC7B,+BAAqC;AACrC,0DAAgE;AAmBhE,SAAS,oBAAoB,CAAC,GAAW,EAAE,mBAA2B;IAClE,6EAA6E;IAC7E,oFAAoF;IACpF,8EAA8E;IAC9E,mFAAmF;IACnF,+EAA+E;IAC/E,+EAA+E;IAC/E,MAAM,WAAW,GAAG,IAAA,WAAI,EAAC,GAAG,EAAE,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,cAAc,EAAE,YAAY,CAAC,CAAC;IAC3F,MAAM,YAAY,GAAG,IAAA,WAAI,EAAC,WAAW,EAAE,cAAc,CAAC,CAAC;IACvD,IAAA,cAAS,EAAC,WAAW,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5C,IAAI,IAAA,eAAU,EAAC,YAAY,CAAC,EAAE,CAAC;QAC3B,IAAA,WAAM,EAAC,YAAY,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC9C,C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E,CAAC;aACjE;YACD;gBACI,OAAO,EAAE,gCAAgC;gBACzC,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,cAAc,EAAE,EAAE,CAAC;aAClE;SACJ;KACJ,CAAC;IAEF,IAAA,cAAS,EAAC,IAAA,cAAO,EAAC,kBAAkB,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,IAAA,kBAAa,EAAC,kBAAkB,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAE5E,OAAO,CAAC,GAAG,CAAC,gCAAgC,aAAa,kBAAkB,cAAc,WAAW,CAAC,CAAC;IACtG,OAAO,CAAC,GAAG,CAAC,mGAAmG,CAAC,CAAC;AACrH,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,KAAK,MAAM;IAAE,IAAA,sBAAO,EAAC,iBAAiB,CAAC,CAAC","sourcesContent":["import { existsSync, readFileSync, writeFileSync, mkdirSync, symlinkSync, rmSync } from 'fs';\nimport { homedir } from 'os';\nimport { join, dirname } from 'path';\nimport { runMain, CliExitError } from '@webpieces/rules-config';\n\ninterface HookEntry {\n matcher: string;\n hooks: Array<{ type: string; command: string }>;\n}\n\ninterface ClaudeSettings {\n hooks?: {\n PreToolUse?: HookEntry[];\n };\n // webpieces-disable no-any-unknown -- opaque settings bag; arbitrary keys allowed\n [key: string]: unknown;\n}\n\ninterface DevHookBackup {\n previousHooks: ClaudeSettings['hooks'] | null;\n}\n\nfunction wireLocalRulesConfig(cwd: string, distRulesConfigPath: string): void {\n // Place the symlink in dist/packages/tooling/node_modules/ — one level above\n // the ai-hook-rules package output but still below the workspace root node_modules.\n // Node's require() resolution walks up from the requiring file and finds this\n // node_modules entry before reaching the workspace root's stale published package.\n // This directory is NOT wiped by any individual package build (each build only\n // cleans its own output subfolder), so it survives a full workspace build too.\n const overrideDir = join(cwd, 'dist', 'packages', 'tooling', 'node_modules', '@webpieces');\n const overrideLink = join(overrideDir, 'rules-config');\n mkdirSync(overrideDir, { recursive: true });\n if (existsSync(overrideLink)) {\n rmSync(overrideLink, { recursive: true });\n }\n symlinkSync(distRulesConfigPath, overrideLink);\n}\n\n// NOTE: this is a dev-only tool, no longer a `wp-*` bin. Run it directly with node against the local\n// build: `node dist/packages/tooling/ai-hook-rules/src/bin/dev-hook-install.js`.\nexport async function runDevHookInstall(): Promise<void> {\n const cwd = process.cwd();\n const adaptersDir = join(cwd, 'dist', 'packages', 'tooling', 'ai-hook-rules', 'src', 'adapters');\n // Mirror production .claude/settings.json: two independent PreToolUse hooks, one per category.\n const rulesHookPath = join(adaptersDir, 'rules-hook.js');\n const guardsHookPath = join(adaptersDir, 'guards-hook.js');\n\n if (!existsSync(rulesHookPath) || !existsSync(guardsHookPath)) {\n console.error(`[dev-hook-install] Local build not found at: ${adaptersDir}`);\n console.error(' Run `pnpm nx run ai-hook-rules:build` first.');\n throw new CliExitError(1, '');\n }\n\n const distRulesConfigPath = join(cwd, 'dist', 'packages', 'tooling', 'rules-config');\n if (!existsSync(distRulesConfigPath)) {\n console.error(`[dev-hook-install] Local rules-config build not found at: ${distRulesConfigPath}`);\n console.error(' Run `pnpm nx run rules-config:build` first.');\n throw new CliExitError(1, '');\n }\n\n const homeDir = homedir();\n const webpiecesDir = join(homeDir, '.webpieces');\n const backupPath = join(webpiecesDir, 'dev-hook-backup.json');\n const claudeSettingsPath = join(homeDir, '.claude', 'settings.json');\n\n if (existsSync(backupPath)) {\n console.error('[dev-hook-install] Dev hook is already installed (backup file exists).');\n console.error(' Run `node dist/packages/tooling/ai-hook-rules/src/bin/dev-hook-uninstall.js` first to remove the current dev hook.');\n throw new CliExitError(1, '');\n }\n\n wireLocalRulesConfig(cwd, distRulesConfigPath);\n\n let settings: ClaudeSettings = {};\n if (existsSync(claudeSettingsPath)) {\n settings = JSON.parse(readFileSync(claudeSettingsPath, 'utf8')) as ClaudeSettings;\n }\n\n // Save whatever hooks exist now (may be undefined/null) so uninstall can restore them\n const backup: DevHookBackup = { previousHooks: settings.hooks ?? null };\n if (!existsSync(webpiecesDir)) {\n mkdirSync(webpiecesDir, { recursive: true });\n }\n writeFileSync(backupPath, JSON.stringify(backup, null, 4) + '\\n');\n\n // Mirror production wiring: rules hook on file tools, guards hook on file + Bash tools.\n settings.hooks = {\n PreToolUse: [\n {\n matcher: 'Write|Edit|MultiEdit',\n hooks: [{ type: 'command', command: `node ${rulesHookPath}` }],\n },\n {\n matcher: 'Write|Edit|MultiEdit|Bash|Read',\n hooks: [{ type: 'command', command: `node ${guardsHookPath}` }],\n },\n ],\n };\n\n mkdirSync(dirname(claudeSettingsPath), { recursive: true });\n writeFileSync(claudeSettingsPath, JSON.stringify(settings, null, 4) + '\\n');\n\n console.log(` Dev hooks installed → node ${rulesHookPath} (rules), node ${guardsHookPath} (guards)`);\n console.log(' Run `node dist/packages/tooling/ai-hook-rules/src/bin/dev-hook-uninstall.js` when done testing.');\n}\n\nif (require.main === module) runMain(runDevHookInstall);\n"]}
@@ -1 +0,0 @@
1
- export declare function runDevHookUninstall(): Promise<void>;