@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,36 +0,0 @@
1
- import { FileOperation } from '@webpieces/hook-runtime';
2
- /**
3
- * Parses Codex's `apply_patch` envelope into the same `FileOperation[]` the rest of the hook already
4
- * understands, so a Codex edit is judged by the identical rules a Claude edit is.
5
- *
6
- * The grammar is MEASURED from a live codex-cli 0.151.0 session, not inferred from a diff format it
7
- * resembles. Two properties of it drive every design choice here:
8
- *
9
- * - ONE envelope carries MANY files with MIXED operations, which is why the result is a LIST of
10
- * `FileOperation` (each with its own kind) rather than one kind for the call.
11
- * - Hunk headers are a BARE `@@` with NO line numbers. A unified-diff `@@ -1,3 +1,4 @@` is therefore
12
- * not a stricter spelling of the same thing — it is an envelope we have never seen, and guessing at
13
- * it is how a guard silently judges the wrong bytes. It is rejected.
14
- *
15
- * Paths are sometimes relative and sometimes absolute (measured: subagents used relative, the
16
- * coordinator absolute), so a relative path is resolved against the payload's `cwd`.
17
- *
18
- * FAIL CLOSED. Every malformed envelope THROWS `InformAiError`, which the hook's one top-level handler
19
- * turns into a deny naming the offending line. A parser that "did its best" on an envelope it did not
20
- * understand would hand the rule engine a subset of the real edit and allow the rest unjudged, which is
21
- * strictly worse than refusing the call.
22
- */
23
- export declare class ApplyPatchParser {
24
- parse(command: string, cwd: string): readonly FileOperation[];
25
- /** `*** Add File: <p>` plus a body of `+` lines → a Write of the joined body. */
26
- private parseAdd;
27
- /**
28
- * `*** Update File: <p>`, an optional `*** Move to: <q>`, then one or more bare-`@@` hunks.
29
- *
30
- * A `Move to` makes the DESTINATION the judged path. That is the file whose bytes will exist after
31
- * the call, so it is the one a path-scoped rule must see; judging the source would let a rename
32
- * into a guarded directory land unjudged.
33
- */
34
- private parseUpdate;
35
- private resolve;
36
- }
@@ -1,154 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ApplyPatchParser = void 0;
4
- const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
6
- const hook_runtime_1 = require("@webpieces/hook-runtime");
7
- const types_1 = require("./types");
8
- const BEGIN_PATCH = '*** Begin Patch';
9
- const END_PATCH = '*** End Patch';
10
- const ADD_FILE = '*** Add File: ';
11
- const UPDATE_FILE = '*** Update File: ';
12
- const DELETE_FILE = '*** Delete File: ';
13
- const MOVE_TO = '*** Move to: ';
14
- const HUNK_HEADER = '@@';
15
- /**
16
- * Parses Codex's `apply_patch` envelope into the same `FileOperation[]` the rest of the hook already
17
- * understands, so a Codex edit is judged by the identical rules a Claude edit is.
18
- *
19
- * The grammar is MEASURED from a live codex-cli 0.151.0 session, not inferred from a diff format it
20
- * resembles. Two properties of it drive every design choice here:
21
- *
22
- * - ONE envelope carries MANY files with MIXED operations, which is why the result is a LIST of
23
- * `FileOperation` (each with its own kind) rather than one kind for the call.
24
- * - Hunk headers are a BARE `@@` with NO line numbers. A unified-diff `@@ -1,3 +1,4 @@` is therefore
25
- * not a stricter spelling of the same thing — it is an envelope we have never seen, and guessing at
26
- * it is how a guard silently judges the wrong bytes. It is rejected.
27
- *
28
- * Paths are sometimes relative and sometimes absolute (measured: subagents used relative, the
29
- * coordinator absolute), so a relative path is resolved against the payload's `cwd`.
30
- *
31
- * FAIL CLOSED. Every malformed envelope THROWS `InformAiError`, which the hook's one top-level handler
32
- * turns into a deny naming the offending line. A parser that "did its best" on an envelope it did not
33
- * understand would hand the rule engine a subset of the real edit and allow the rest unjudged, which is
34
- * strictly worse than refusing the call.
35
- */
36
- class ApplyPatchParser {
37
- parse(command, cwd) {
38
- const lines = command.split('\n');
39
- const begin = lines.findIndex((l) => l.trim() === BEGIN_PATCH);
40
- if (begin < 0) {
41
- throw new types_1.InformAiError(`[apply-patch] envelope has no '${BEGIN_PATCH}' line — refusing to judge a patch this parser does not recognise.`);
42
- }
43
- const end = lines.findIndex((l) => l.trim() === END_PATCH);
44
- if (end < 0 || end < begin) {
45
- throw new types_1.InformAiError(`[apply-patch] envelope has no '${END_PATCH}' line after '${BEGIN_PATCH}' — refusing to judge a truncated patch.`);
46
- }
47
- const body = lines.slice(begin + 1, end);
48
- const ops = [];
49
- let index = 0;
50
- while (index < body.length) {
51
- const line = body[index];
52
- if (line.startsWith(ADD_FILE)) {
53
- index = this.parseAdd(body, index, cwd, ops);
54
- }
55
- else if (line.startsWith(DELETE_FILE)) {
56
- ops.push(new hook_runtime_1.FileOperation('Delete', new types_1.NormalizedToolInput(this.resolve(line.slice(DELETE_FILE.length), cwd), [])));
57
- index += 1;
58
- }
59
- else if (line.startsWith(UPDATE_FILE)) {
60
- index = this.parseUpdate(body, index, cwd, ops);
61
- }
62
- else if (line.trim() === '') {
63
- index += 1;
64
- }
65
- else {
66
- throw new types_1.InformAiError(`[apply-patch] unexpected line outside any file section: ${JSON.stringify(line)}`);
67
- }
68
- }
69
- if (ops.length === 0) {
70
- throw new types_1.InformAiError('[apply-patch] envelope names no files — refusing to allow a patch whose targets could not be read.');
71
- }
72
- return ops;
73
- }
74
- /** `*** Add File: <p>` plus a body of `+` lines → a Write of the joined body. */
75
- parseAdd(body, start, cwd, ops) {
76
- const filePath = this.resolve(body[start].slice(ADD_FILE.length), cwd);
77
- const content = [];
78
- let index = start + 1;
79
- while (index < body.length && !body[index].startsWith('*** ')) {
80
- const line = body[index];
81
- if (!line.startsWith('+')) {
82
- throw new types_1.InformAiError(`[apply-patch] '${ADD_FILE.trim()}' body line must begin with '+', got ${JSON.stringify(line)}`);
83
- }
84
- content.push(line.slice(1));
85
- index += 1;
86
- }
87
- ops.push(new hook_runtime_1.FileOperation('Write', new types_1.NormalizedToolInput(filePath, [new types_1.NormalizedEdit('', content.join('\n'))])));
88
- return index;
89
- }
90
- /**
91
- * `*** Update File: <p>`, an optional `*** Move to: <q>`, then one or more bare-`@@` hunks.
92
- *
93
- * A `Move to` makes the DESTINATION the judged path. That is the file whose bytes will exist after
94
- * the call, so it is the one a path-scoped rule must see; judging the source would let a rename
95
- * into a guarded directory land unjudged.
96
- */
97
- parseUpdate(body, start, cwd, ops) {
98
- let index = start + 1;
99
- let filePath = this.resolve(body[start].slice(UPDATE_FILE.length), cwd);
100
- if (index < body.length && body[index].startsWith(MOVE_TO)) {
101
- filePath = this.resolve(body[index].slice(MOVE_TO.length), cwd);
102
- index += 1;
103
- }
104
- const edits = [];
105
- while (index < body.length && !body[index].startsWith('*** ')) {
106
- const header = body[index];
107
- if (header.trim() !== HUNK_HEADER) {
108
- throw new types_1.InformAiError(`[apply-patch] malformed hunk header ${JSON.stringify(header)} — a Codex hunk header is a bare '@@' with no line numbers.`);
109
- }
110
- index += 1;
111
- const oldLines = [];
112
- const newLines = [];
113
- while (index < body.length && !body[index].startsWith('*** ') && body[index].trim() !== HUNK_HEADER) {
114
- const line = body[index];
115
- // A bare empty line is a CONTEXT line whose content is empty — the leading space is
116
- // routinely stripped by whatever carried the patch, so treating it as malformed would
117
- // deny ordinary edits to files with blank lines.
118
- if (line === '') {
119
- oldLines.push('');
120
- newLines.push('');
121
- }
122
- else if (line.startsWith(' ')) {
123
- oldLines.push(line.slice(1));
124
- newLines.push(line.slice(1));
125
- }
126
- else if (line.startsWith('-')) {
127
- oldLines.push(line.slice(1));
128
- }
129
- else if (line.startsWith('+')) {
130
- newLines.push(line.slice(1));
131
- }
132
- else {
133
- throw new types_1.InformAiError(`[apply-patch] hunk line must begin with ' ', '-' or '+', got ${JSON.stringify(line)}`);
134
- }
135
- index += 1;
136
- }
137
- edits.push(new types_1.NormalizedEdit(oldLines.join('\n'), newLines.join('\n')));
138
- }
139
- if (edits.length === 0) {
140
- throw new types_1.InformAiError(`[apply-patch] '${UPDATE_FILE.trim()}' section for ${filePath} carries no '@@' hunk — refusing to allow an edit whose content could not be read.`);
141
- }
142
- ops.push(new hook_runtime_1.FileOperation('Edit', new types_1.NormalizedToolInput(filePath, edits)));
143
- return index;
144
- }
145
- resolve(rawPath, cwd) {
146
- const trimmed = rawPath.trim();
147
- if (trimmed === '') {
148
- throw new types_1.InformAiError('[apply-patch] a file directive named an empty path.');
149
- }
150
- return path.isAbsolute(trimmed) ? trimmed : path.resolve(cwd, trimmed);
151
- }
152
- }
153
- exports.ApplyPatchParser = ApplyPatchParser;
154
- //# sourceMappingURL=apply-patch-parse.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-patch-parse.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/apply-patch-parse.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAE7B,0DAAwD;AACxD,mCAA6E;AAE7E,MAAM,WAAW,GAAG,iBAAiB,CAAC;AACtC,MAAM,SAAS,GAAG,eAAe,CAAC;AAClC,MAAM,QAAQ,GAAG,gBAAgB,CAAC;AAClC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,WAAW,GAAG,mBAAmB,CAAC;AACxC,MAAM,OAAO,GAAG,eAAe,CAAC;AAChC,MAAM,WAAW,GAAG,IAAI,CAAC;AAEzB;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAa,gBAAgB;IACzB,KAAK,CAAC,OAAe,EAAE,GAAW;QAC9B,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAClC,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KAAK,WAAW,CAAC,CAAC;QAChF,IAAI,KAAK,GAAG,CAAC,EAAE,CAAC;YACZ,MAAM,IAAI,qBAAa,CAAC,kCAAkC,WAAW,oEAAoE,CAAC,CAAC;QAC/I,CAAC;QACD,MAAM,GAAG,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,KA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KAAK,CAAC,EAAE,CAAC;YACrB,MAAM,IAAI,qBAAa,CAAC,kBAAkB,WAAW,CAAC,IAAI,EAAE,iBAAiB,QAAQ,oFAAoF,CAAC,CAAC;QAC/K,CAAC;QACD,GAAG,CAAC,IAAI,CAAC,IAAI,4BAAa,CAAC,MAAM,EAAE,IAAI,2BAAmB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QAC9E,OAAO,KAAK,CAAC;IACjB,CAAC;IAEO,OAAO,CAAC,OAAe,EAAE,GAAW;QACxC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,EAAE,CAAC;QAC/B,IAAI,OAAO,KAAK,EAAE,EAAE,CAAC;YACjB,MAAM,IAAI,qBAAa,CAAC,qDAAqD,CAAC,CAAC;QACnF,CAAC;QACD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CACJ;AAhHD,4CAgHC","sourcesContent":["import * as path from 'path';\n\nimport { FileOperation } from '@webpieces/hook-runtime';\nimport { NormalizedEdit, NormalizedToolInput, InformAiError } from './types';\n\nconst BEGIN_PATCH = '*** Begin Patch';\nconst END_PATCH = '*** End Patch';\nconst ADD_FILE = '*** Add File: ';\nconst UPDATE_FILE = '*** Update File: ';\nconst DELETE_FILE = '*** Delete File: ';\nconst MOVE_TO = '*** Move to: ';\nconst HUNK_HEADER = '@@';\n\n/**\n * Parses Codex's `apply_patch` envelope into the same `FileOperation[]` the rest of the hook already\n * understands, so a Codex edit is judged by the identical rules a Claude edit is.\n *\n * The grammar is MEASURED from a live codex-cli 0.151.0 session, not inferred from a diff format it\n * resembles. Two properties of it drive every design choice here:\n *\n * - ONE envelope carries MANY files with MIXED operations, which is why the result is a LIST of\n * `FileOperation` (each with its own kind) rather than one kind for the call.\n * - Hunk headers are a BARE `@@` with NO line numbers. A unified-diff `@@ -1,3 +1,4 @@` is therefore\n * not a stricter spelling of the same thing — it is an envelope we have never seen, and guessing at\n * it is how a guard silently judges the wrong bytes. It is rejected.\n *\n * Paths are sometimes relative and sometimes absolute (measured: subagents used relative, the\n * coordinator absolute), so a relative path is resolved against the payload's `cwd`.\n *\n * FAIL CLOSED. Every malformed envelope THROWS `InformAiError`, which the hook's one top-level handler\n * turns into a deny naming the offending line. A parser that \"did its best\" on an envelope it did not\n * understand would hand the rule engine a subset of the real edit and allow the rest unjudged, which is\n * strictly worse than refusing the call.\n */\nexport class ApplyPatchParser {\n parse(command: string, cwd: string): readonly FileOperation[] {\n const lines = command.split('\\n');\n const begin = lines.findIndex((l: string): boolean => l.trim() === BEGIN_PATCH);\n if (begin < 0) {\n throw new InformAiError(`[apply-patch] envelope has no '${BEGIN_PATCH}' line — refusing to judge a patch this parser does not recognise.`);\n }\n const end = lines.findIndex((l: string): boolean => l.trim() === END_PATCH);\n if (end < 0 || end < begin) {\n throw new InformAiError(`[apply-patch] envelope has no '${END_PATCH}' line after '${BEGIN_PATCH}' — refusing to judge a truncated patch.`);\n }\n\n const body = lines.slice(begin + 1, end);\n const ops: FileOperation[] = [];\n let index = 0;\n while (index < body.length) {\n const line = body[index];\n if (line.startsWith(ADD_FILE)) {\n index = this.parseAdd(body, index, cwd, ops);\n } else if (line.startsWith(DELETE_FILE)) {\n ops.push(new FileOperation('Delete', new NormalizedToolInput(this.resolve(line.slice(DELETE_FILE.length), cwd), [])));\n index += 1;\n } else if (line.startsWith(UPDATE_FILE)) {\n index = this.parseUpdate(body, index, cwd, ops);\n } else if (line.trim() === '') {\n index += 1;\n } else {\n throw new InformAiError(`[apply-patch] unexpected line outside any file section: ${JSON.stringify(line)}`);\n }\n }\n if (ops.length === 0) {\n throw new InformAiError('[apply-patch] envelope names no files — refusing to allow a patch whose targets could not be read.');\n }\n return ops;\n }\n\n /** `*** Add File: <p>` plus a body of `+` lines → a Write of the joined body. */\n private parseAdd(body: readonly string[], start: number, cwd: string, ops: FileOperation[]): number {\n const filePath = this.resolve(body[start].slice(ADD_FILE.length), cwd);\n const content: string[] = [];\n let index = start + 1;\n while (index < body.length && !body[index].startsWith('*** ')) {\n const line = body[index];\n if (!line.startsWith('+')) {\n throw new InformAiError(`[apply-patch] '${ADD_FILE.trim()}' body line must begin with '+', got ${JSON.stringify(line)}`);\n }\n content.push(line.slice(1));\n index += 1;\n }\n ops.push(new FileOperation('Write', new NormalizedToolInput(filePath, [new NormalizedEdit('', content.join('\\n'))])));\n return index;\n }\n\n /**\n * `*** Update File: <p>`, an optional `*** Move to: <q>`, then one or more bare-`@@` hunks.\n *\n * A `Move to` makes the DESTINATION the judged path. That is the file whose bytes will exist after\n * the call, so it is the one a path-scoped rule must see; judging the source would let a rename\n * into a guarded directory land unjudged.\n */\n private parseUpdate(body: readonly string[], start: number, cwd: string, ops: FileOperation[]): number {\n let index = start + 1;\n let filePath = this.resolve(body[start].slice(UPDATE_FILE.length), cwd);\n if (index < body.length && body[index].startsWith(MOVE_TO)) {\n filePath = this.resolve(body[index].slice(MOVE_TO.length), cwd);\n index += 1;\n }\n const edits: NormalizedEdit[] = [];\n while (index < body.length && !body[index].startsWith('*** ')) {\n const header = body[index];\n if (header.trim() !== HUNK_HEADER) {\n throw new InformAiError(`[apply-patch] malformed hunk header ${JSON.stringify(header)} — a Codex hunk header is a bare '@@' with no line numbers.`);\n }\n index += 1;\n const oldLines: string[] = [];\n const newLines: string[] = [];\n while (index < body.length && !body[index].startsWith('*** ') && body[index].trim() !== HUNK_HEADER) {\n const line = body[index];\n // A bare empty line is a CONTEXT line whose content is empty — the leading space is\n // routinely stripped by whatever carried the patch, so treating it as malformed would\n // deny ordinary edits to files with blank lines.\n if (line === '') {\n oldLines.push('');\n newLines.push('');\n } else if (line.startsWith(' ')) {\n oldLines.push(line.slice(1));\n newLines.push(line.slice(1));\n } else if (line.startsWith('-')) {\n oldLines.push(line.slice(1));\n } else if (line.startsWith('+')) {\n newLines.push(line.slice(1));\n } else {\n throw new InformAiError(`[apply-patch] hunk line must begin with ' ', '-' or '+', got ${JSON.stringify(line)}`);\n }\n index += 1;\n }\n edits.push(new NormalizedEdit(oldLines.join('\\n'), newLines.join('\\n')));\n }\n if (edits.length === 0) {\n throw new InformAiError(`[apply-patch] '${UPDATE_FILE.trim()}' section for ${filePath} carries no '@@' hunk — refusing to allow an edit whose content could not be read.`);\n }\n ops.push(new FileOperation('Edit', new NormalizedToolInput(filePath, edits)));\n return index;\n }\n\n private resolve(rawPath: string, cwd: string): string {\n const trimmed = rawPath.trim();\n if (trimmed === '') {\n throw new InformAiError('[apply-patch] a file directive named an empty path.');\n }\n return path.isAbsolute(trimmed) ? trimmed : path.resolve(cwd, trimmed);\n }\n}\n"]}
@@ -1,10 +0,0 @@
1
- import { EffectiveTree } from './effective-tree';
2
- import { GovernedPath } from './target-tree';
3
- import { ToolKind, NormalizedToolInput, EditContext, FileContext, BashContext } from './types';
4
- export declare class BuiltContexts {
5
- readonly fileContext: FileContext;
6
- readonly editContexts: readonly EditContext[];
7
- constructor(fileContext: FileContext, editContexts: readonly EditContext[]);
8
- }
9
- export declare function buildContexts(toolKind: ToolKind, input: NormalizedToolInput, workspaceRoot: string, governed: GovernedPath): BuiltContexts;
10
- export declare function buildBashContext(command: string, tree: EffectiveTree): BashContext;
@@ -1,66 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuiltContexts = void 0;
4
- exports.buildContexts = buildContexts;
5
- exports.buildBashContext = buildBashContext;
6
- const tslib_1 = require("tslib");
7
- const fs = tslib_1.__importStar(require("fs"));
8
- const strip_ts_noise_1 = require("./strip-ts-noise");
9
- const disable_directives_1 = require("./disable-directives");
10
- const types_1 = require("./types");
11
- class BuiltContexts {
12
- fileContext;
13
- editContexts;
14
- constructor(fileContext, editContexts) {
15
- this.fileContext = fileContext;
16
- this.editContexts = editContexts;
17
- }
18
- }
19
- exports.BuiltContexts = BuiltContexts;
20
- function buildContexts(toolKind, input, workspaceRoot, governed) {
21
- const filePath = input.filePath;
22
- const relativePath = governed.relativePath;
23
- const edits = input.edits;
24
- const currentFileLines = readCurrentFileLines(filePath);
25
- let linesAdded = 0;
26
- let linesRemoved = 0;
27
- for (const e of edits) {
28
- linesAdded += countLines(e.newString);
29
- linesRemoved += countLines(e.oldString);
30
- }
31
- const projectedFileLines = toolKind === 'Write'
32
- ? countLines(edits.length > 0 ? edits[0].newString : '')
33
- : currentFileLines + linesAdded - linesRemoved;
34
- const fileContext = new types_1.FileContext(toolKind, filePath, relativePath, workspaceRoot, currentFileLines, linesAdded, linesRemoved, projectedFileLines, governed.treeRoot, governed.treeRelativePath);
35
- const editContexts = edits.map((e, idx) => {
36
- const addedContent = e.newString;
37
- const stripped = (0, strip_ts_noise_1.stripTsNoise)(addedContent);
38
- const isLineDisabled = (0, disable_directives_1.createIsLineDisabled)(addedContent);
39
- return new types_1.EditContext(toolKind, idx, edits.length, filePath, relativePath, workspaceRoot, addedContent, stripped, addedContent.split('\n'), stripped.split('\n'), e.oldString, isLineDisabled);
40
- });
41
- return new BuiltContexts(fileContext, editContexts);
42
- }
43
- // The bash context is built from the RESOLVED tree, not the shell's cwd: `tree.root` is the worktree
44
- // the command acts on (what the guards must judge) while `tree.governedRoot` still owns the config.
45
- // webpieces-disable no-function-outside-class -- sibling of buildContexts() above; this module is a pair of module-scope context factories and a lone class for one of them would break its shape
46
- function buildBashContext(command, tree) {
47
- return new types_1.BashContext(command, tree.root, tree.effectiveCwd, tree.governedRoot);
48
- }
49
- function readCurrentFileLines(filePath) {
50
- // eslint-disable-next-line @webpieces/no-unmanaged-exceptions
51
- try {
52
- const content = fs.readFileSync(filePath, 'utf8');
53
- return countLines(content);
54
- }
55
- catch (err) {
56
- // eslint-disable-next-line @webpieces/catch-error-pattern -- file-not-found is expected for new Write targets
57
- void err;
58
- return 0;
59
- }
60
- }
61
- function countLines(s) {
62
- if (!s)
63
- return 0;
64
- return s.split('\n').length;
65
- }
66
- //# sourceMappingURL=build-context.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-context.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/build-context.ts"],"names":[],"mappings":";;;AAqBA,sCAyDC;AAKD,4CAEC;;AArFD,+CAAyB;AAIzB,qDAAgD;AAChD,6DAA4D;AAC5D,mCAGiB;AAEjB,MAAa,aAAa;IACb,WAAW,CAAc;IACzB,YAAY,CAAyB;IAE9C,YAAY,WAAwB,EAAE,YAAoC;QACtE,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;IACrC,CAAC;CACJ;AARD,sCAQC;AAED,SAAgB,aAAa,CACzB,QAAkB,EAClB,KAA0B,EAC1B,aAAqB,EACrB,QAAsB;IAEtB,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAChC,MAAM,YAAY,GAAG,QAAQ,CAAC,YAAY,CAAC;IAC3C,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAE1B,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IACxD,IAAI,UAAU,GAAG,CAAC,CAAC;IACnB,IAAI,YAAY,GAAG,CAAC,CAAC;IACrB,KAAK,MAAM,CAAC,IAAI,KAAK,EAAE,CAAC;QACpB,UAAU,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;QACtC,YAAY,IAAI,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,MAAM,kBAAkB,GACpB,QAAQ,KAAK,OAAO;QAChB,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QACxD,CAAC,CAAC,gBAAgB,GAAG,UAAU,GAAG,YAAY,CAAC;IAEvD,MAAM,WAAW,G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,OAAO,GAAY,EAAE,CAAC;QACpB,8GAA8G;QAC9G,KAAK,GAAG,CAAC;QACT,OAAO,CAAC,CAAC;IACb,CAAC;AACL,CAAC;AAED,SAAS,UAAU,CAAC,CAAS;IACzB,IAAI,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC;IACjB,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC;AAChC,CAAC","sourcesContent":["import * as fs from 'fs';\n\nimport { EffectiveTree } from './effective-tree';\nimport { GovernedPath } from './target-tree';\nimport { stripTsNoise } from './strip-ts-noise';\nimport { createIsLineDisabled } from './disable-directives';\nimport {\n ToolKind, NormalizedToolInput, NormalizedEdit,\n EditContext, FileContext, BashContext,\n} from './types';\n\nexport class BuiltContexts {\n readonly fileContext: FileContext;\n readonly editContexts: readonly EditContext[];\n\n constructor(fileContext: FileContext, editContexts: readonly EditContext[]) {\n this.fileContext = fileContext;\n this.editContexts = editContexts;\n }\n}\n\nexport function buildContexts(\n toolKind: ToolKind,\n input: NormalizedToolInput,\n workspaceRoot: string,\n governed: GovernedPath,\n): BuiltContexts {\n const filePath = input.filePath;\n const relativePath = governed.relativePath;\n const edits = input.edits;\n\n const currentFileLines = readCurrentFileLines(filePath);\n let linesAdded = 0;\n let linesRemoved = 0;\n for (const e of edits) {\n linesAdded += countLines(e.newString);\n linesRemoved += countLines(e.oldString);\n }\n\n const projectedFileLines =\n toolKind === 'Write'\n ? countLines(edits.length > 0 ? edits[0].newString : '')\n : currentFileLines + linesAdded - linesRemoved;\n\n const fileContext = new FileContext(\n toolKind,\n filePath,\n relativePath,\n workspaceRoot,\n currentFileLines,\n linesAdded,\n linesRemoved,\n projectedFileLines,\n governed.treeRoot,\n governed.treeRelativePath,\n );\n\n const editContexts = edits.map((e, idx) => {\n const addedContent = e.newString;\n const stripped = stripTsNoise(addedContent);\n const isLineDisabled = createIsLineDisabled(addedContent);\n return new EditContext(\n toolKind,\n idx,\n edits.length,\n filePath,\n relativePath,\n workspaceRoot,\n addedContent,\n stripped,\n addedContent.split('\\n'),\n stripped.split('\\n'),\n e.oldString,\n isLineDisabled,\n );\n });\n\n return new BuiltContexts(fileContext, editContexts);\n}\n\n// The bash context is built from the RESOLVED tree, not the shell's cwd: `tree.root` is the worktree\n// the command acts on (what the guards must judge) while `tree.governedRoot` still owns the config.\n// webpieces-disable no-function-outside-class -- sibling of buildContexts() above; this module is a pair of module-scope context factories and a lone class for one of them would break its shape\nexport function buildBashContext(command: string, tree: EffectiveTree): BashContext {\n return new BashContext(command, tree.root, tree.effectiveCwd, tree.governedRoot);\n}\n\nfunction readCurrentFileLines(filePath: string): number {\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n const content = fs.readFileSync(filePath, 'utf8');\n return countLines(content);\n } catch (err: unknown) {\n // eslint-disable-next-line @webpieces/catch-error-pattern -- file-not-found is expected for new Write targets\n void err;\n return 0;\n }\n}\n\nfunction countLines(s: string): number {\n if (!s) return 0;\n return s.split('\\n').length;\n}\n"]}
@@ -1,122 +0,0 @@
1
- /**
2
- * Shared shell-command scanning for the bash guards.
3
- *
4
- * A guard that bans a command family (`git merge`, `git push`, …) must answer one question
5
- * precisely: *does this command actually invoke `git <subcommand>`?* A bare
6
- * `/\bgit\s+merge\b/.test(command)` gets that wrong in both directions:
7
- *
8
- * - False positive: `grep 'git merge main' notes.md` or `echo "git rebase main"` merely MENTION
9
- * the phrase. A diagnostic grep was blocked this way while triaging the incident that motivated
10
- * the merge/rebase ban.
11
- * - False positive: `\b` sits between `e` and `-`, so `/\bgit\s+merge\b/` matches the read-only
12
- * `git merge-base origin/main HEAD` — which appears in this repo's own documented build command.
13
- *
14
- * Both classes vanish if you tokenize instead of substring-match: a command invokes git only when a
15
- * segment's first word IS `git`, and the subcommand is then an exact token (`merge-base` is simply
16
- * not the token `merge`). No lookahead regex needed.
17
- */
18
- /**
19
- * The shell operator that JOINED one segment to the one before it. `'none'` for the first segment.
20
- *
21
- * This used to be a single boolean, `pipedInto`, and the widening is what makes composition
22
- * judgeable. A pipe is only one of the joins whose MEANING differs: `cure && work` short-circuits, so
23
- * the work cannot run when the cure failed, while `cure ; work` discards the cure's exit code and
24
- * runs the work anyway. A boolean that answered only "was it a pipe?" threw that distinction away,
25
- * and a guard cannot refuse the dangerous join while allowing the safe one without it.
26
- */
27
- export type SegmentJoin = 'none' | '|' | '&&' | '||' | ';' | '&' | '\n' | '(' | ')';
28
- /**
29
- * One invoked segment of a command, plus the operator that joined it to its predecessor.
30
- *
31
- * `join === '|'` is what separates `git log | grep foo` (grep consumes the pipe — reads no file) from
32
- * `grep foo src/` (grep reads the working tree). A guard that cares about which FILES a command
33
- * reads cannot tell those apart from the segment text alone, because splitting on `|` throws exactly
34
- * that fact away. `join === '&&'` vs `';'` is the same argument one operator over — see
35
- * {@link SegmentJoin}. Data-only, so a class (per CLAUDE.md).
36
- */
37
- export declare class CommandSegment {
38
- text: string;
39
- join: SegmentJoin;
40
- constructor(text: string, join: SegmentJoin);
41
- }
42
- export declare class CommandScanner {
43
- /**
44
- * Split a raw command into individually-invoked segments.
45
- *
46
- * Splits on `&&`, `||`, `;`, `|`, `&`, newline, and the `(`/`)` of subshells and `$(…)` command
47
- * substitution — the last of these matters, since it means `--base=$(git rebase main)` is scanned
48
- * as its own `git rebase main` segment rather than hiding inside a `pnpm …` segment.
49
- *
50
- * Quoted spans are opaque: a separator inside quotes is literal text, so
51
- * `git commit -m "fix; ship it"` stays one segment. (Corollary: a `$(…)` nested inside double
52
- * quotes is not split out. Bash would expand it; we do not scan it. Contrived enough to accept.)
53
- */
54
- commandSegments(command: string): readonly string[];
55
- /**
56
- * commandSegments, but each segment also carries the OPERATOR that joined it to its predecessor.
57
- * Only a guard reasoning about which files a segment reads, or about whether a failed first
58
- * segment can stop the rest, needs that; everything else uses commandSegments, which is this
59
- * method with the join dropped.
60
- */
61
- segmentsWithJoins(command: string): readonly CommandSegment[];
62
- /**
63
- * One segment's shell words, with wrappers/env-assignments stripped, so `words('sudo cat a b')`
64
- * is `['cat', 'a', 'b']`. The public view of the same tokenizer gitSubcommand uses — a guard that
65
- * must inspect a NON-git command's arguments (which paths does this `grep` actually read?) needs
66
- * the tokens, and re-splitting on whitespace in the guard would get quoting wrong.
67
- */
68
- words(segment: string): readonly string[];
69
- /**
70
- * The git subcommand a segment invokes, or null when the segment does not invoke git at all
71
- * (a different program, a mere mention inside quotes, an empty segment).
72
- *
73
- * Returns the subcommand as an EXACT token: `git merge-base …` yields `'merge-base'`, never `'merge'`.
74
- */
75
- gitSubcommand(segment: string): string | null;
76
- /**
77
- * gitSubcommand, for a caller that already holds the segment's effective words (ShellSegmentScan
78
- * strips leading shell keywords, so `do git status` must be resolved from ITS words, not from the
79
- * raw segment text where `do` is the command).
80
- */
81
- gitSubcommandOf(words: readonly string[]): string | null;
82
- /**
83
- * The ARGUMENTS following `git <subcommand>` in this segment, or null when the segment does not
84
- * invoke that subcommand.
85
- *
86
- * `gitSubcommand` answers *which* subcommand; a guard that judges the subcommand's own flags needs
87
- * the tokens after it, and slicing them in the guard would mean re-deriving where the subcommand
88
- * sits — i.e. re-deriving the `sudo` / `env VAR=x` / `-C <path>` skipping this class exists to own.
89
- * `git -C /x commit -m "msg"` yields `['-m', 'msg']`, never `['/x', 'commit', '-m', 'msg']`.
90
- *
91
- * The tokens are QUOTE-STRIPPED (see tokenize), so a quoted argument arrives as ONE token holding
92
- * its literal text — newlines, backticks and all. That is what makes an argument's CONTENT
93
- * inspectable at all.
94
- */
95
- gitSubcommandArgs(segment: string, subcommand: string): readonly string[] | null;
96
- /** Index of the subcommand token in already-prefix-stripped words, or -1 when git is not invoked. */
97
- private gitSubcommandIndex;
98
- /**
99
- * The segment's words with the package-manager WRAPPER stripped, so `pnpm exec vitest run` and
100
- * `vitest run` reduce to the same words. `pnpm --silent run build-all` → `['build-all']`.
101
- *
102
- * Lives HERE rather than in a guard because two guards now need it and they must agree: one blocks a
103
- * whole-repo build, the other blocks piping a build's output. If they disagreed about whether
104
- * `npx wp-build` is `wp-build`, one of them would have a spelling-shaped side door — which is exactly
105
- * the failure mode the runner stripping exists to close.
106
- */
107
- runnerStrippedWords(segment: string): readonly string[];
108
- /** `./node_modules/.bin/nx` and `/usr/local/bin/pnpm.cmd` are the programs `nx` and `pnpm`. */
109
- programName(token: string): string;
110
- /** True when a package-manager runner precedes the program (`pnpm …`, `npx …`). */
111
- viaRunner(segment: string): boolean;
112
- /** True when this segment actually invokes `git <subcommand>`. */
113
- invokesGit(segment: string, subcommand: string): boolean;
114
- /** True when ANY segment of the command invokes one of `subcommands`. */
115
- commandInvokesAnyGit(command: string, subcommands: readonly string[]): boolean;
116
- /**
117
- * Split one segment into shell words, dropping quote characters (so the ARGUMENT of
118
- * `echo "git merge main"` is the single word `git merge main`, never the word `git`).
119
- */
120
- private tokenize;
121
- private stripPrefixes;
122
- }