@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,101 +0,0 @@
1
- import { ExcludePaths } from '@webpieces/rules-config';
2
- import { CommandScanner } from './command-scan';
3
- /**
4
- * One path the denied command NAMED that `excludePaths` already exempts, plus how to reach it.
5
- *
6
- * Data-only, so a class (per CLAUDE.md).
7
- *
8
- * `cdDirectory` is the whole point of the class rather than a bare string: it is a directory that
9
- * ITSELF satisfies `globMatches` against one of the configured globs, or null when no such directory
10
- * exists for this reference. Callers must never invent one — see ExcludedPathEscapeScan for why a
11
- * naive `dirname` is wrong exactly when it looks most obviously right.
12
- */
13
- export declare class ExcludedPathReference {
14
- /** The referenced path, workspace-relative, as it was matched. */
15
- readonly referencedPath: string;
16
- /** The `excludePaths` glob that matched it — quoted back so the agent need not re-derive it. */
17
- readonly matchedGlob: string;
18
- /** A directory a `cd` may legally land in (matches a glob on its own), or null when none does. */
19
- readonly cdDirectory: string | null;
20
- /** `referencedPath` re-expressed relative to `cdDirectory`; '' when there is no `cdDirectory`. */
21
- readonly pathFromCdDirectory: string;
22
- constructor(referencedPath: string, matchedGlob: string, cdDirectory: string | null, pathFromCdDirectory: string);
23
- }
24
- /**
25
- * Finds the paths a BASH command names that the top-level `excludePaths` already exempts.
26
- *
27
- * WHY this exists: the bash guards judge the shell's effective CWD, not the paths in the command, so
28
- * `cat .webpieces/tasks.md` at the repo root is DENIED even though that exact file is exempt from
29
- * every guard and was reachable, that instant, through Read/Write. Every remedy the deny body printed
30
- * was a git state change — strictly more destructive than the one it omitted. This class supplies the
31
- * missing sentence; it changes no verdict.
32
- *
33
- * A token is treated as a candidate path with no filesystem check: whether it exists says nothing
34
- * about whether it is exempt, and a stat per token on the blocking hook path is exactly the cost these
35
- * guards avoid. Non-path tokens (a `grep` pattern, a `sed` script) simply match no glob.
36
- */
37
- export declare class ExcludedPathEscapeScan {
38
- private readonly scanner;
39
- private readonly workspaceRoot;
40
- private readonly effectiveCwd;
41
- /**
42
- * `effectiveCwd` is the directory the command really runs in, after its own leading `cd` — the
43
- * same base ContentReadScan resolves relative operands against. RELATIVE tokens are resolved
44
- * there and ABSOLUTE ones normalised straight to workspace-relative, which is how
45
- * `cat /abs/path/to/repo/.webpieces/tasks.md` reaches the same verdict as `cat .webpieces/tasks.md`.
46
- */
47
- constructor(scanner: CommandScanner, workspaceRoot: string, effectiveCwd: string);
48
- /**
49
- * Every excluded path this command references, in command order, de-duplicated.
50
- *
51
- * Scans EVERY segment, not just a leading `cd`: `cat x`, `grep -n foo x`, `sed -n '1,5p' x` and a
52
- * path inside an `&&` compound all count, because the agent's next move depends on the file it
53
- * wanted, wherever in the line it named it.
54
- */
55
- references(command: string, ex: ExcludePaths): readonly ExcludedPathReference[];
56
- private reference;
57
- /**
58
- * A directory the agent may `cd` into and have the guards actually stand down, or null.
59
- *
60
- * THE TRAP: the bash path matches the relative cwd with `globMatches`, which compiles
61
- * `.webpieces/**` to the anchored `/^\.webpieces\/.*$/` — the `/` is a LITERAL, so the bare
62
- * directory `.webpieces` does NOT match its own glob. `cd .webpieces && cat tasks.md` is still
63
- * denied. Emitting that would be worse than emitting nothing: it looks authoritative and costs a
64
- * turn to disprove. So the directory is only offered when it passes the very same matcher the
65
- * runner will use, and the renderer says so plainly when nothing does.
66
- */
67
- private cdDirectory;
68
- private matchingGlob;
69
- /**
70
- * Workspace-relative form of a token, or null when it is not a path inside this workspace.
71
- *
72
- * `~`-rooted and out-of-tree paths are nothing to do with this repo's exclusions, and the
73
- * workspace root itself ('') matches no glob by construction.
74
- */
75
- private workspaceRelative;
76
- /**
77
- * Every token that could name a file: each segment's words minus the command word itself and
78
- * minus flags. Deliberately generous — a token that is not a path matches no glob, while a token
79
- * dropped by a cleverer filter is a file the agent is never told it can read.
80
- */
81
- private candidateTokens;
82
- }
83
- /**
84
- * Renders the leading stanza of a bash deny body: the Read/Write escape the agent already has, and —
85
- * when one genuinely exists — the `cd` that makes bash itself work.
86
- *
87
- * It goes at the TOP of the report, above the git remedies, because the agent acts on the first
88
- * actionable thing it reads. The live incident this fixes had the agent create a branch in a human's
89
- * working tree to record a row in a gitignored scratch file; the cheap, side-effect-free path was one
90
- * sentence away and never printed. Returns '' when the command names no excluded path, so a repo
91
- * without exemptions — and every command that names nothing exempt — sees no extra noise.
92
- */
93
- export declare class ExcludedPathEscapeHint {
94
- private readonly scan;
95
- /** `effectiveCwd` is the directory the command really runs in — see ExcludedPathEscapeScan. */
96
- constructor(workspaceRoot: string, effectiveCwd: string);
97
- render(command: string, ex: ExcludePaths): string;
98
- private bashLines;
99
- private cdLines;
100
- private noCdLines;
101
- }
@@ -1,236 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ExcludedPathEscapeHint = exports.ExcludedPathEscapeScan = exports.ExcludedPathReference = void 0;
4
- const tslib_1 = require("tslib");
5
- const path = tslib_1.__importStar(require("path"));
6
- const command_scan_1 = require("./command-scan");
7
- const load_rules_1 = require("./load-rules");
8
- /**
9
- * One path the denied command NAMED that `excludePaths` already exempts, plus how to reach it.
10
- *
11
- * Data-only, so a class (per CLAUDE.md).
12
- *
13
- * `cdDirectory` is the whole point of the class rather than a bare string: it is a directory that
14
- * ITSELF satisfies `globMatches` against one of the configured globs, or null when no such directory
15
- * exists for this reference. Callers must never invent one — see ExcludedPathEscapeScan for why a
16
- * naive `dirname` is wrong exactly when it looks most obviously right.
17
- */
18
- class ExcludedPathReference {
19
- /** The referenced path, workspace-relative, as it was matched. */
20
- referencedPath;
21
- /** The `excludePaths` glob that matched it — quoted back so the agent need not re-derive it. */
22
- matchedGlob;
23
- /** A directory a `cd` may legally land in (matches a glob on its own), or null when none does. */
24
- cdDirectory;
25
- /** `referencedPath` re-expressed relative to `cdDirectory`; '' when there is no `cdDirectory`. */
26
- pathFromCdDirectory;
27
- constructor(referencedPath, matchedGlob, cdDirectory, pathFromCdDirectory) {
28
- this.referencedPath = referencedPath;
29
- this.matchedGlob = matchedGlob;
30
- this.cdDirectory = cdDirectory;
31
- this.pathFromCdDirectory = pathFromCdDirectory;
32
- }
33
- }
34
- exports.ExcludedPathReference = ExcludedPathReference;
35
- /**
36
- * Finds the paths a BASH command names that the top-level `excludePaths` already exempts.
37
- *
38
- * WHY this exists: the bash guards judge the shell's effective CWD, not the paths in the command, so
39
- * `cat .webpieces/tasks.md` at the repo root is DENIED even though that exact file is exempt from
40
- * every guard and was reachable, that instant, through Read/Write. Every remedy the deny body printed
41
- * was a git state change — strictly more destructive than the one it omitted. This class supplies the
42
- * missing sentence; it changes no verdict.
43
- *
44
- * A token is treated as a candidate path with no filesystem check: whether it exists says nothing
45
- * about whether it is exempt, and a stat per token on the blocking hook path is exactly the cost these
46
- * guards avoid. Non-path tokens (a `grep` pattern, a `sed` script) simply match no glob.
47
- */
48
- class ExcludedPathEscapeScan {
49
- scanner;
50
- workspaceRoot;
51
- effectiveCwd;
52
- /**
53
- * `effectiveCwd` is the directory the command really runs in, after its own leading `cd` — the
54
- * same base ContentReadScan resolves relative operands against. RELATIVE tokens are resolved
55
- * there and ABSOLUTE ones normalised straight to workspace-relative, which is how
56
- * `cat /abs/path/to/repo/.webpieces/tasks.md` reaches the same verdict as `cat .webpieces/tasks.md`.
57
- */
58
- constructor(scanner, workspaceRoot, effectiveCwd) {
59
- this.scanner = scanner;
60
- this.workspaceRoot = workspaceRoot;
61
- this.effectiveCwd = effectiveCwd;
62
- }
63
- /**
64
- * Every excluded path this command references, in command order, de-duplicated.
65
- *
66
- * Scans EVERY segment, not just a leading `cd`: `cat x`, `grep -n foo x`, `sed -n '1,5p' x` and a
67
- * path inside an `&&` compound all count, because the agent's next move depends on the file it
68
- * wanted, wherever in the line it named it.
69
- */
70
- references(command, ex) {
71
- if (ex.paths.length === 0)
72
- return [];
73
- const found = [];
74
- const seen = new Set();
75
- for (const token of this.candidateTokens(command)) {
76
- const relative = this.workspaceRelative(token);
77
- if (relative === null || seen.has(relative))
78
- continue;
79
- seen.add(relative);
80
- const glob = this.matchingGlob(relative, ex);
81
- if (glob === null)
82
- continue;
83
- found.push(this.reference(relative, glob, ex));
84
- }
85
- return found;
86
- }
87
- // Build the reference, including the `cd` target — the ONE subtle part, see cdDirectory below.
88
- reference(relative, glob, ex) {
89
- const dir = this.cdDirectory(relative, ex);
90
- return new ExcludedPathReference(relative, glob, dir, dir === null ? '' : path.relative(dir, relative));
91
- }
92
- /**
93
- * A directory the agent may `cd` into and have the guards actually stand down, or null.
94
- *
95
- * THE TRAP: the bash path matches the relative cwd with `globMatches`, which compiles
96
- * `.webpieces/**` to the anchored `/^\.webpieces\/.*$/` — the `/` is a LITERAL, so the bare
97
- * directory `.webpieces` does NOT match its own glob. `cd .webpieces && cat tasks.md` is still
98
- * denied. Emitting that would be worse than emitting nothing: it looks authoritative and costs a
99
- * turn to disprove. So the directory is only offered when it passes the very same matcher the
100
- * runner will use, and the renderer says so plainly when nothing does.
101
- */
102
- cdDirectory(relative, ex) {
103
- const dir = path.dirname(relative);
104
- if (dir === '.' || dir === '' || dir === relative)
105
- return null;
106
- return this.matchingGlob(dir, ex) === null ? null : dir;
107
- }
108
- // The first configured glob this workspace-relative path satisfies, under the runner's OWN matcher
109
- // (globMatches, load-rules.ts) — never a looser one, or the stanza would promise an exemption the
110
- // guards do not grant.
111
- matchingGlob(relative, ex) {
112
- for (const pattern of ex.paths) {
113
- if ((0, load_rules_1.globMatches)(pattern, relative))
114
- return pattern;
115
- }
116
- return null;
117
- }
118
- /**
119
- * Workspace-relative form of a token, or null when it is not a path inside this workspace.
120
- *
121
- * `~`-rooted and out-of-tree paths are nothing to do with this repo's exclusions, and the
122
- * workspace root itself ('') matches no glob by construction.
123
- */
124
- workspaceRelative(token) {
125
- const cleaned = token.replace(REDIRECT_PREFIX, '');
126
- if (cleaned === '' || cleaned.startsWith('~'))
127
- return null;
128
- const absolute = path.isAbsolute(cleaned) ? cleaned : path.resolve(this.effectiveCwd, cleaned);
129
- const relative = path.relative(this.workspaceRoot, absolute);
130
- if (relative === '' || relative.startsWith('..'))
131
- return null;
132
- return relative;
133
- }
134
- /**
135
- * Every token that could name a file: each segment's words minus the command word itself and
136
- * minus flags. Deliberately generous — a token that is not a path matches no glob, while a token
137
- * dropped by a cleverer filter is a file the agent is never told it can read.
138
- */
139
- candidateTokens(command) {
140
- const tokens = [];
141
- for (const segment of this.scanner.commandSegments(command)) {
142
- const words = this.scanner.words(segment);
143
- for (let i = 1; i < words.length; i++) {
144
- if (words[i].startsWith('-'))
145
- continue;
146
- tokens.push(words[i]);
147
- }
148
- }
149
- return tokens;
150
- }
151
- }
152
- exports.ExcludedPathEscapeScan = ExcludedPathEscapeScan;
153
- // A redirection glued to its target (`>out.log`, `2>>err.log`, `<in.txt`) — strip the operator so the
154
- // target is scanned as the path it is.
155
- const REDIRECT_PREFIX = /^\d*(?:>>?|<)/;
156
- /**
157
- * Renders the leading stanza of a bash deny body: the Read/Write escape the agent already has, and —
158
- * when one genuinely exists — the `cd` that makes bash itself work.
159
- *
160
- * It goes at the TOP of the report, above the git remedies, because the agent acts on the first
161
- * actionable thing it reads. The live incident this fixes had the agent create a branch in a human's
162
- * working tree to record a row in a gitignored scratch file; the cheap, side-effect-free path was one
163
- * sentence away and never printed. Returns '' when the command names no excluded path, so a repo
164
- * without exemptions — and every command that names nothing exempt — sees no extra noise.
165
- */
166
- class ExcludedPathEscapeHint {
167
- scan;
168
- /** `effectiveCwd` is the directory the command really runs in — see ExcludedPathEscapeScan. */
169
- constructor(workspaceRoot, effectiveCwd) {
170
- this.scan = new ExcludedPathEscapeScan(new command_scan_1.CommandScanner(), workspaceRoot, effectiveCwd);
171
- }
172
- render(command, ex) {
173
- const references = this.scan.references(command, ex);
174
- if (references.length === 0)
175
- return '';
176
- const lines = [];
177
- lines.push('✅ YOU CAN USE THE READ/WRITE TOOLS RIGHT NOW — no git operation needed.');
178
- lines.push(' These paths are in excludePaths and are exempt from every guard:');
179
- for (const glob of ex.paths)
180
- lines.push(` ${glob}`);
181
- lines.push(` Your command referenced: ${references.map((r) => r.referencedPath).join(', ')}`);
182
- // Scoped to the FILE, deliberately. The stanza fires on any rule block whose command names an
183
- // exempt path, and `git push … && cat .webpieces/tasks.md` is blocked for the push — for which
184
- // Read/Write substitutes for nothing. Claiming the remedies below were optional would be false.
185
- lines.push(' Read/Write/Edit reaches that file RIGHT NOW, with no git operation at all.');
186
- lines.push(' Anything ELSE this command does — a git/gh operation, a build — still needs the');
187
- lines.push(' remedies below.');
188
- const bash = this.bashLines(references);
189
- if (bash.length > 0) {
190
- lines.push('');
191
- for (const line of bash)
192
- lines.push(line);
193
- }
194
- lines.push('');
195
- return lines.join('\n');
196
- }
197
- // The bash half: the `cd` when one matches, the honest refusal to invent one when none does, and
198
- // silence when there is not even a directory worth naming.
199
- bashLines(references) {
200
- const withCd = references.find((r) => r.cdDirectory !== null);
201
- if (withCd !== undefined)
202
- return this.cdLines(withCd);
203
- // A workspace-ROOT-level file — matched by a file-shaped glob like `*.md` — has no directory to
204
- // name: `dirname` is `.`, which no excludePaths glob can usefully exempt (the relative cwd at
205
- // the root is '', so `.` would never match) and which reads as "exempt the whole repo". Say
206
- // nothing about bash rather than something false.
207
- const nested = references.find((r) => path.dirname(r.referencedPath) !== '.');
208
- return nested === undefined ? [] : this.noCdLines(nested);
209
- }
210
- // A `cd` the guards will actually honour: its directory passed globMatches in the scan.
211
- cdLines(withCd) {
212
- return [
213
- '✅ OR KEEP USING BASH — put a `cd` into the excluded tree FIRST:',
214
- ` cd ${String(withCd.cdDirectory)} && <your command, writing \`${withCd.referencedPath}\` as \`${withCd.pathFromCdDirectory}\`>`,
215
- ' The guard resolves a LEADING `cd` and judges that directory, so this runs.',
216
- ' It must be the first thing in the command: no leading VAR= assignment,',
217
- ' no subshell wrapper — those defeat the resolution.',
218
- ];
219
- }
220
- // No directory on the way to the file matches a glob on its own, so there is no `cd` to offer.
221
- // Say WHY and give the one-line config edit that would create one, rather than printing a `cd`
222
- // that would be denied.
223
- noCdLines(first) {
224
- const dir = path.dirname(first.referencedPath);
225
- return [
226
- '⚠️ A `cd` CANNOT rescue bash here, so do not try one.',
227
- ` \`${dir}\` (the directory itself) matches no excludePaths glob: \`${first.matchedGlob}\` compiles to`,
228
- ' an anchored regex whose `/` is literal, so the bare directory fails it and a `cd` into',
229
- ' it is STILL denied. That form is deliberately not printed here — it looks right and is not.',
230
- ' Use Read/Write/Edit above — or, to make bash work here too, list the bare directory',
231
- ` alongside the glob in webpieces.config.json → excludePaths: ["${dir}", "${first.matchedGlob}"]`,
232
- ];
233
- }
234
- }
235
- exports.ExcludedPathEscapeHint = ExcludedPathEscapeHint;
236
- //# sourceMappingURL=excluded-path-escape.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"excluded-path-escape.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/excluded-path-escape.ts"],"names":[],"mappings":";;;;AAAA,mDAA6B;AAI7B,iDAAgD;AAChD,6CAA2C;AAE3C;;;;;;;;;GASG;AACH,MAAa,qBAAqB;IAC9B,kEAAkE;IACzD,cAAc,CAAS;IAChC,gGAAgG;IACvF,WAAW,CAAS;IAC7B,kGAAkG;IACzF,WAAW,CAAgB;IACpC,kGAAkG;IACzF,mBAAmB,CAAS;IAErC,YACI,cAAsB,EACtB,WAAmB,EACnB,WAA0B,EAC1B,mBAA2B;QAE3B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;IACnD,CAAC;CACJ;AArBD,sDAqBC;AAED;;;;;;;;;;;;GAYG;AACH,MAAa,sBAAsB;IACd,OAAO,CAAiB;IACxB,aAAa,CAAS;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gGAAgG;QAChG,8FAA8F;QAC9F,4FAA4F;QAC5F,kDAAkD;QAClD,MAAM,MAAM,GAAG,UAAU,CAAC,IAAI,CAC1B,CAAC,CAAwB,EAAW,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,cAAc,CAAC,KAAK,GAAG,CAChF,CAAC;QACF,OAAO,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IAC9D,CAAC;IAED,wFAAwF;IAChF,OAAO,CAAC,MAA6B;QACzC,OAAO;YACH,iEAAiE;YACjE,WAAW,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,gCAAgC,MAAM,CAAC,cAAc,WAAW,MAAM,CAAC,mBAAmB,KAAK;YACpI,+EAA+E;YAC/E,2EAA2E;YAC3E,uDAAuD;SAC1D,CAAC;IACN,CAAC;IAED,+FAA+F;IAC/F,+FAA+F;IAC/F,wBAAwB;IAChB,SAAS,CAAC,KAA4B;QAC1C,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;QAC/C,OAAO;YACH,wDAAwD;YACxD,QAAQ,GAAG,6DAA6D,KAAK,CAAC,WAAW,gBAAgB;YACzG,2FAA2F;YAC3F,gGAAgG;YAChG,wFAAwF;YACxF,oEAAoE,GAAG,OAAO,KAAK,CAAC,WAAW,IAAI;SACtG,CAAC;IACN,CAAC;CACJ;AAxED,wDAwEC","sourcesContent":["import * as path from 'path';\n\nimport { ExcludePaths } from '@webpieces/rules-config';\n\nimport { CommandScanner } from './command-scan';\nimport { globMatches } from './load-rules';\n\n/**\n * One path the denied command NAMED that `excludePaths` already exempts, plus how to reach it.\n *\n * Data-only, so a class (per CLAUDE.md).\n *\n * `cdDirectory` is the whole point of the class rather than a bare string: it is a directory that\n * ITSELF satisfies `globMatches` against one of the configured globs, or null when no such directory\n * exists for this reference. Callers must never invent one — see ExcludedPathEscapeScan for why a\n * naive `dirname` is wrong exactly when it looks most obviously right.\n */\nexport class ExcludedPathReference {\n /** The referenced path, workspace-relative, as it was matched. */\n readonly referencedPath: string;\n /** The `excludePaths` glob that matched it — quoted back so the agent need not re-derive it. */\n readonly matchedGlob: string;\n /** A directory a `cd` may legally land in (matches a glob on its own), or null when none does. */\n readonly cdDirectory: string | null;\n /** `referencedPath` re-expressed relative to `cdDirectory`; '' when there is no `cdDirectory`. */\n readonly pathFromCdDirectory: string;\n\n constructor(\n referencedPath: string,\n matchedGlob: string,\n cdDirectory: string | null,\n pathFromCdDirectory: string,\n ) {\n this.referencedPath = referencedPath;\n this.matchedGlob = matchedGlob;\n this.cdDirectory = cdDirectory;\n this.pathFromCdDirectory = pathFromCdDirectory;\n }\n}\n\n/**\n * Finds the paths a BASH command names that the top-level `excludePaths` already exempts.\n *\n * WHY this exists: the bash guards judge the shell's effective CWD, not the paths in the command, so\n * `cat .webpieces/tasks.md` at the repo root is DENIED even though that exact file is exempt from\n * every guard and was reachable, that instant, through Read/Write. Every remedy the deny body printed\n * was a git state change — strictly more destructive than the one it omitted. This class supplies the\n * missing sentence; it changes no verdict.\n *\n * A token is treated as a candidate path with no filesystem check: whether it exists says nothing\n * about whether it is exempt, and a stat per token on the blocking hook path is exactly the cost these\n * guards avoid. Non-path tokens (a `grep` pattern, a `sed` script) simply match no glob.\n */\nexport class ExcludedPathEscapeScan {\n private readonly scanner: CommandScanner;\n private readonly workspaceRoot: string;\n private readonly effectiveCwd: string;\n\n /**\n * `effectiveCwd` is the directory the command really runs in, after its own leading `cd` — the\n * same base ContentReadScan resolves relative operands against. RELATIVE tokens are resolved\n * there and ABSOLUTE ones normalised straight to workspace-relative, which is how\n * `cat /abs/path/to/repo/.webpieces/tasks.md` reaches the same verdict as `cat .webpieces/tasks.md`.\n */\n constructor(scanner: CommandScanner, workspaceRoot: string, effectiveCwd: string) {\n this.scanner = scanner;\n this.workspaceRoot = workspaceRoot;\n this.effectiveCwd = effectiveCwd;\n }\n\n /**\n * Every excluded path this command references, in command order, de-duplicated.\n *\n * Scans EVERY segment, not just a leading `cd`: `cat x`, `grep -n foo x`, `sed -n '1,5p' x` and a\n * path inside an `&&` compound all count, because the agent's next move depends on the file it\n * wanted, wherever in the line it named it.\n */\n references(command: string, ex: ExcludePaths): readonly ExcludedPathReference[] {\n if (ex.paths.length === 0) return [];\n\n const found: ExcludedPathReference[] = [];\n const seen = new Set<string>();\n for (const token of this.candidateTokens(command)) {\n const relative = this.workspaceRelative(token);\n if (relative === null || seen.has(relative)) continue;\n seen.add(relative);\n const glob = this.matchingGlob(relative, ex);\n if (glob === null) continue;\n found.push(this.reference(relative, glob, ex));\n }\n return found;\n }\n\n // Build the reference, including the `cd` target — the ONE subtle part, see cdDirectory below.\n private reference(relative: string, glob: string, ex: ExcludePaths): ExcludedPathReference {\n const dir = this.cdDirectory(relative, ex);\n return new ExcludedPathReference(\n relative, glob, dir, dir === null ? '' : path.relative(dir, relative),\n );\n }\n\n /**\n * A directory the agent may `cd` into and have the guards actually stand down, or null.\n *\n * THE TRAP: the bash path matches the relative cwd with `globMatches`, which compiles\n * `.webpieces/**` to the anchored `/^\\.webpieces\\/.*$/` — the `/` is a LITERAL, so the bare\n * directory `.webpieces` does NOT match its own glob. `cd .webpieces && cat tasks.md` is still\n * denied. Emitting that would be worse than emitting nothing: it looks authoritative and costs a\n * turn to disprove. So the directory is only offered when it passes the very same matcher the\n * runner will use, and the renderer says so plainly when nothing does.\n */\n private cdDirectory(relative: string, ex: ExcludePaths): string | null {\n const dir = path.dirname(relative);\n if (dir === '.' || dir === '' || dir === relative) return null;\n return this.matchingGlob(dir, ex) === null ? null : dir;\n }\n\n // The first configured glob this workspace-relative path satisfies, under the runner's OWN matcher\n // (globMatches, load-rules.ts) — never a looser one, or the stanza would promise an exemption the\n // guards do not grant.\n private matchingGlob(relative: string, ex: ExcludePaths): string | null {\n for (const pattern of ex.paths) {\n if (globMatches(pattern, relative)) return pattern;\n }\n return null;\n }\n\n /**\n * Workspace-relative form of a token, or null when it is not a path inside this workspace.\n *\n * `~`-rooted and out-of-tree paths are nothing to do with this repo's exclusions, and the\n * workspace root itself ('') matches no glob by construction.\n */\n private workspaceRelative(token: string): string | null {\n const cleaned = token.replace(REDIRECT_PREFIX, '');\n if (cleaned === '' || cleaned.startsWith('~')) return null;\n const absolute = path.isAbsolute(cleaned) ? cleaned : path.resolve(this.effectiveCwd, cleaned);\n const relative = path.relative(this.workspaceRoot, absolute);\n if (relative === '' || relative.startsWith('..')) return null;\n return relative;\n }\n\n /**\n * Every token that could name a file: each segment's words minus the command word itself and\n * minus flags. Deliberately generous — a token that is not a path matches no glob, while a token\n * dropped by a cleverer filter is a file the agent is never told it can read.\n */\n private candidateTokens(command: string): readonly string[] {\n const tokens: string[] = [];\n for (const segment of this.scanner.commandSegments(command)) {\n const words = this.scanner.words(segment);\n for (let i = 1; i < words.length; i++) {\n if (words[i].startsWith('-')) continue;\n tokens.push(words[i]);\n }\n }\n return tokens;\n }\n}\n\n// A redirection glued to its target (`>out.log`, `2>>err.log`, `<in.txt`) — strip the operator so the\n// target is scanned as the path it is.\nconst REDIRECT_PREFIX = /^\\d*(?:>>?|<)/;\n\n/**\n * Renders the leading stanza of a bash deny body: the Read/Write escape the agent already has, and —\n * when one genuinely exists — the `cd` that makes bash itself work.\n *\n * It goes at the TOP of the report, above the git remedies, because the agent acts on the first\n * actionable thing it reads. The live incident this fixes had the agent create a branch in a human's\n * working tree to record a row in a gitignored scratch file; the cheap, side-effect-free path was one\n * sentence away and never printed. Returns '' when the command names no excluded path, so a repo\n * without exemptions — and every command that names nothing exempt — sees no extra noise.\n */\nexport class ExcludedPathEscapeHint {\n private readonly scan: ExcludedPathEscapeScan;\n\n /** `effectiveCwd` is the directory the command really runs in — see ExcludedPathEscapeScan. */\n constructor(workspaceRoot: string, effectiveCwd: string) {\n this.scan = new ExcludedPathEscapeScan(new CommandScanner(), workspaceRoot, effectiveCwd);\n }\n\n render(command: string, ex: ExcludePaths): string {\n const references = this.scan.references(command, ex);\n if (references.length === 0) return '';\n\n const lines: string[] = [];\n lines.push('✅ YOU CAN USE THE READ/WRITE TOOLS RIGHT NOW — no git operation needed.');\n lines.push(' These paths are in excludePaths and are exempt from every guard:');\n for (const glob of ex.paths) lines.push(` ${glob}`);\n lines.push(` Your command referenced: ${references.map((r: ExcludedPathReference): string => r.referencedPath).join(', ')}`);\n // Scoped to the FILE, deliberately. The stanza fires on any rule block whose command names an\n // exempt path, and `git push … && cat .webpieces/tasks.md` is blocked for the push — for which\n // Read/Write substitutes for nothing. Claiming the remedies below were optional would be false.\n lines.push(' Read/Write/Edit reaches that file RIGHT NOW, with no git operation at all.');\n lines.push(' Anything ELSE this command does — a git/gh operation, a build — still needs the');\n lines.push(' remedies below.');\n const bash = this.bashLines(references);\n if (bash.length > 0) {\n lines.push('');\n for (const line of bash) lines.push(line);\n }\n lines.push('');\n return lines.join('\\n');\n }\n\n // The bash half: the `cd` when one matches, the honest refusal to invent one when none does, and\n // silence when there is not even a directory worth naming.\n private bashLines(references: readonly ExcludedPathReference[]): readonly string[] {\n const withCd = references.find((r: ExcludedPathReference): boolean => r.cdDirectory !== null);\n if (withCd !== undefined) return this.cdLines(withCd);\n // A workspace-ROOT-level file — matched by a file-shaped glob like `*.md` — has no directory to\n // name: `dirname` is `.`, which no excludePaths glob can usefully exempt (the relative cwd at\n // the root is '', so `.` would never match) and which reads as \"exempt the whole repo\". Say\n // nothing about bash rather than something false.\n const nested = references.find(\n (r: ExcludedPathReference): boolean => path.dirname(r.referencedPath) !== '.',\n );\n return nested === undefined ? [] : this.noCdLines(nested);\n }\n\n // A `cd` the guards will actually honour: its directory passed globMatches in the scan.\n private cdLines(withCd: ExcludedPathReference): readonly string[] {\n return [\n '✅ OR KEEP USING BASH — put a `cd` into the excluded tree FIRST:',\n ` cd ${String(withCd.cdDirectory)} && <your command, writing \\`${withCd.referencedPath}\\` as \\`${withCd.pathFromCdDirectory}\\`>`,\n ' The guard resolves a LEADING `cd` and judges that directory, so this runs.',\n ' It must be the first thing in the command: no leading VAR= assignment,',\n ' no subshell wrapper — those defeat the resolution.',\n ];\n }\n\n // No directory on the way to the file matches a glob on its own, so there is no `cd` to offer.\n // Say WHY and give the one-line config edit that would create one, rather than printing a `cd`\n // that would be denied.\n private noCdLines(first: ExcludedPathReference): readonly string[] {\n const dir = path.dirname(first.referencedPath);\n return [\n '⚠️ A `cd` CANNOT rescue bash here, so do not try one.',\n ` \\`${dir}\\` (the directory itself) matches no excludePaths glob: \\`${first.matchedGlob}\\` compiles to`,\n ' an anchored regex whose `/` is literal, so the bare directory fails it and a `cd` into',\n ' it is STILL denied. That form is deliberately not printed here — it looks right and is not.',\n ' Use Read/Write/Edit above — or, to make bash work here too, list the bare directory',\n ` alongside the glob in webpieces.config.json → excludePaths: [\"${dir}\", \"${first.matchedGlob}\"]`,\n ];\n }\n}\n"]}
@@ -1,23 +0,0 @@
1
- import { ExcludePaths } from '@webpieces/rules-config';
2
- import { EffectiveTree } from './effective-tree';
3
- import { GovernedPath } from './target-tree';
4
- import type { Rule } from './types';
5
- /**
6
- * L1's FILTER — which rules have jurisdiction over one path — and the one helper that builds its
7
- * argument for the bash surface.
8
- *
9
- * Lifted out of runner.ts, which the file-size rule had outgrown. It is a natural seam rather than a
10
- * page-count fix: this is the only place `excludePaths` and the hard-coded `.webpieces/` skip are
11
- * consulted, and runner.ts is otherwise the four tool ENTRY POINTS and their L0/L1 preamble.
12
- */
13
- export declare function filterByExcludedPaths(rules: readonly Rule[], governed: GovernedPath, ex: ExcludePaths): readonly Rule[];
14
- /**
15
- * The bash surface's GovernedPath, built from the tree EffectiveTreeResolver has already classified —
16
- * so it costs no extra git call on the hook's blocking path.
17
- *
18
- * Both spellings of the command's effective cwd: relative to the governed root for the excludePaths
19
- * globs, and relative to the OWNING tree for the `.webpieces/` skip — which for
20
- * `cd <worktree>/.webpieces && …` is the worktree's state dir, not the primary's. Both are '' for a
21
- * command with no leading `cd`, which matches no glob and is not the state dir.
22
- */
23
- export declare function bashGovernedPath(tree: EffectiveTree, workspaceRoot: string): GovernedPath;
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.filterByExcludedPaths = filterByExcludedPaths;
4
- exports.bashGovernedPath = bashGovernedPath;
5
- const tslib_1 = require("tslib");
6
- const path = tslib_1.__importStar(require("path"));
7
- const rules_config_1 = require("@webpieces/rules-config");
8
- const load_rules_1 = require("./load-rules");
9
- const target_tree_1 = require("./target-tree");
10
- /**
11
- * L1's FILTER — which rules have jurisdiction over one path — and the one helper that builds its
12
- * argument for the bash surface.
13
- *
14
- * Lifted out of runner.ts, which the file-size rule had outgrown. It is a natural seam rather than a
15
- * page-count fix: this is the only place `excludePaths` and the hard-coded `.webpieces/` skip are
16
- * consulted, and runner.ts is otherwise the four tool ENTRY POINTS and their L0/L1 preamble.
17
- */
18
- // Drop every rule excluded for this path (webpieces.config.json → excludePaths). ONE glob list: a path
19
- // listed there is hands-off for code-style rules and file-scoped guards alike, because webpieces either
20
- // governs a path or it does not. Per-rule carve-outs live in the rule's own `excludePaths`.
21
- // This is L1's FILTER (not a table row) — see guards/L1-location.md.
22
- //
23
- // It takes a GovernedPath and not a bare string because the two questions below are asked against
24
- // DIFFERENT roots, and answering both from the governed-root spelling is issue #851's secondary defect:
25
- // the excludePaths globs are authored against the governed root, while `.webpieces/` is the state dir OF
26
- // A TREE and a linked worktree has its own. One argument carrying both spellings is what stops a caller
27
- // picking the wrong one; see GovernedPath.
28
- // webpieces-disable no-function-outside-class -- L1's filter, a pure predicate over one path and one glob list; it is called from four module-scope entry points in runner.ts and a class here would be a namespace with no state
29
- function filterByExcludedPaths(rules, governed, ex) {
30
- // webpieces' OWN gitignored state dir is never governed, config or no config. Ahead of the list on
31
- // purpose — see isWebpiecesStateDir for why it is code and not a seeded glob. Asked about the
32
- // OWNING tree's spelling, so `<primary>/.claude/worktrees/agent-X/.webpieces/...` is exempt for the
33
- // identical reason `<primary>/.webpieces/...` is: nothing under it is tracked, reviewable or
34
- // revertable in the tree it belongs to.
35
- if ((0, rules_config_1.isWebpiecesStateDir)(governed.treeRelativePath))
36
- return [];
37
- if (ex.paths.some((p) => (0, load_rules_1.globMatches)(p, governed.relativePath)))
38
- return [];
39
- return rules;
40
- }
41
- /**
42
- * The bash surface's GovernedPath, built from the tree EffectiveTreeResolver has already classified —
43
- * so it costs no extra git call on the hook's blocking path.
44
- *
45
- * Both spellings of the command's effective cwd: relative to the governed root for the excludePaths
46
- * globs, and relative to the OWNING tree for the `.webpieces/` skip — which for
47
- * `cd <worktree>/.webpieces && …` is the worktree's state dir, not the primary's. Both are '' for a
48
- * command with no leading `cd`, which matches no glob and is not the state dir.
49
- */
50
- // webpieces-disable no-function-outside-class -- the bash-side constructor for the value above, beside it
51
- function bashGovernedPath(tree, workspaceRoot) {
52
- return new target_tree_1.GovernedPath(path.relative(workspaceRoot, tree.effectiveCwd), path.relative(tree.root, tree.effectiveCwd), tree.root);
53
- }
54
- //# sourceMappingURL=excluded-paths.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"excluded-paths.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/excluded-paths.ts"],"names":[],"mappings":";;AA6BA,sDASC;AAYD,4CAMC;;AAxDD,mDAA6B;AAE7B,0DAA4E;AAG5E,6CAA2C;AAC3C,+CAA6C;AAG7C;;;;;;;GAOG;AAEH,uGAAuG;AACvG,wGAAwG;AACxG,4FAA4F;AAC5F,qEAAqE;AACrE,EAAE;AACF,kGAAkG;AAClG,wGAAwG;AACxG,yGAAyG;AACzG,wGAAwG;AACxG,2CAA2C;AAC3C,kOAAkO;AAClO,SAAgB,qBAAqB,CAAC,KAAsB,EAAE,QAAsB,EAAE,EAAgB;IAClG,mGAAmG;IACnG,8FAA8F;IAC9F,oGAAoG;IACpG,6FAA6F;IAC7F,wCAAwC;IACxC,IAAI,IAAA,kCAAmB,EAAC,QAAQ,CAAC,gBAAgB,CAAC;QAAE,OAAO,EAAE,CAAC;IAC9D,IAAI,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAS,EAAW,EAAE,CAAC,IAAA,wBAAW,EAAC,CAAC,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAC5F,OAAO,KAAK,CAAC;AACjB,CAAC;AAED;;;;;;;;GAQG;AACH,0GAA0G;AAC1G,SAAgB,gBAAgB,CAAC,IAAmB,EAAE,aAAqB;IACvE,OAAO,IAAI,0BAAY,CACnB,IAAI,CAAC,QAAQ,CAAC,aAAa,EAAE,IAAI,CAAC,YAAY,CAAC,EAC/C,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,YAAY,CAAC,EAC3C,IAAI,CAAC,IAAI,CACZ,CAAC;AACN,CAAC","sourcesContent":["import * as path from 'path';\n\nimport { ExcludePaths, isWebpiecesStateDir } from '@webpieces/rules-config';\n\nimport { EffectiveTree } from './effective-tree';\nimport { globMatches } from './load-rules';\nimport { GovernedPath } from './target-tree';\nimport type { Rule } from './types';\n\n/**\n * L1's FILTER — which rules have jurisdiction over one path — and the one helper that builds its\n * argument for the bash surface.\n *\n * Lifted out of runner.ts, which the file-size rule had outgrown. It is a natural seam rather than a\n * page-count fix: this is the only place `excludePaths` and the hard-coded `.webpieces/` skip are\n * consulted, and runner.ts is otherwise the four tool ENTRY POINTS and their L0/L1 preamble.\n */\n\n// Drop every rule excluded for this path (webpieces.config.json → excludePaths). ONE glob list: a path\n// listed there is hands-off for code-style rules and file-scoped guards alike, because webpieces either\n// governs a path or it does not. Per-rule carve-outs live in the rule's own `excludePaths`.\n// This is L1's FILTER (not a table row) — see guards/L1-location.md.\n//\n// It takes a GovernedPath and not a bare string because the two questions below are asked against\n// DIFFERENT roots, and answering both from the governed-root spelling is issue #851's secondary defect:\n// the excludePaths globs are authored against the governed root, while `.webpieces/` is the state dir OF\n// A TREE and a linked worktree has its own. One argument carrying both spellings is what stops a caller\n// picking the wrong one; see GovernedPath.\n// webpieces-disable no-function-outside-class -- L1's filter, a pure predicate over one path and one glob list; it is called from four module-scope entry points in runner.ts and a class here would be a namespace with no state\nexport function filterByExcludedPaths(rules: readonly Rule[], governed: GovernedPath, ex: ExcludePaths): readonly Rule[] {\n // webpieces' OWN gitignored state dir is never governed, config or no config. Ahead of the list on\n // purpose — see isWebpiecesStateDir for why it is code and not a seeded glob. Asked about the\n // OWNING tree's spelling, so `<primary>/.claude/worktrees/agent-X/.webpieces/...` is exempt for the\n // identical reason `<primary>/.webpieces/...` is: nothing under it is tracked, reviewable or\n // revertable in the tree it belongs to.\n if (isWebpiecesStateDir(governed.treeRelativePath)) return [];\n if (ex.paths.some((p: string): boolean => globMatches(p, governed.relativePath))) return [];\n return rules;\n}\n\n/**\n * The bash surface's GovernedPath, built from the tree EffectiveTreeResolver has already classified —\n * so it costs no extra git call on the hook's blocking path.\n *\n * Both spellings of the command's effective cwd: relative to the governed root for the excludePaths\n * globs, and relative to the OWNING tree for the `.webpieces/` skip — which for\n * `cd <worktree>/.webpieces && …` is the worktree's state dir, not the primary's. Both are '' for a\n * command with no leading `cd`, which matches no glob and is not the state dir.\n */\n// webpieces-disable no-function-outside-class -- the bash-side constructor for the value above, beside it\nexport function bashGovernedPath(tree: EffectiveTree, workspaceRoot: string): GovernedPath {\n return new GovernedPath(\n path.relative(workspaceRoot, tree.effectiveCwd),\n path.relative(tree.root, tree.effectiveCwd),\n tree.root,\n );\n}\n"]}
@@ -1,40 +0,0 @@
1
- import { Option } from '@webpieces/rules-config';
2
- /**
3
- * Framework-owned `// webpieces-disable` escape hatch for a rule, gated by the team's
4
- * `disableAllowed` config (default true). `comment` is the exact suppress syntax to show
5
- * (usually `// webpieces-disable <rule> -- <reason>`; max-file-lines uses the eslint form).
6
- * When `allowed` is false the framework prints a "must be followed" line instead of the escape.
7
- */
8
- export declare class DisableEscape {
9
- readonly allowed: boolean;
10
- readonly comment: string;
11
- constructor(allowed: boolean, comment: string);
12
- }
13
- /**
14
- * Structured fix guidance shown under a violation in a blocked-write / blocked-bash report.
15
- *
16
- * A rule authors its user-facing text once here: a required `violation` (the "what's wrong"
17
- * line — the rule-level default for the `→` line; a dynamic per-occurrence `Violation.message`
18
- * overrides it), a `mainMessage` (fix prose, or a lead-in to the options), an optional list of
19
- * genuinely distinct `fixOptions`, and — for the disable-able code-style rules — a framework-
20
- * owned `escape`.
21
- *
22
- * The framework (report.ts / `formatFixOptions`) — not the rule author — owns the "Fix Option N:"
23
- * numbering, the "(preferred)" tag, and the escape/`disableAllowed` rendering. So a multi-line
24
- * message can never be mis-split into fake options, and authors never hand-write those labels.
25
- *
26
- * `Option` is NOT defined here: it lives in `@webpieces/rules-config` (`fix-option.ts`) because
27
- * `RuleFailError` — thrown by BOTH engines — carries the same class. One cure shape, one definition,
28
- * one import path. Import it from `@webpieces/rules-config`, never from this module.
29
- */
30
- export declare class FixHint {
31
- /** Required: the "what's wrong" line (rule-level default for the `→` line). */
32
- readonly violation: string;
33
- /** Required (may be ''): fix prose, or a lead-in to the options. Multi-line ok. */
34
- readonly mainMessage: string;
35
- /** Real fixes only — NEVER the disable escape (that is `escape`). */
36
- readonly fixOptions: readonly Option[];
37
- /** Present only for disable-able rules; absent for guards. */
38
- readonly escape?: DisableEscape;
39
- constructor(violation: string, mainMessage: string, fixOptions?: readonly Option[], escape?: DisableEscape);
40
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.FixHint = exports.DisableEscape = void 0;
4
- /**
5
- * Framework-owned `// webpieces-disable` escape hatch for a rule, gated by the team's
6
- * `disableAllowed` config (default true). `comment` is the exact suppress syntax to show
7
- * (usually `// webpieces-disable <rule> -- <reason>`; max-file-lines uses the eslint form).
8
- * When `allowed` is false the framework prints a "must be followed" line instead of the escape.
9
- */
10
- class DisableEscape {
11
- allowed;
12
- comment;
13
- constructor(allowed, comment) {
14
- this.allowed = allowed;
15
- this.comment = comment;
16
- }
17
- }
18
- exports.DisableEscape = DisableEscape;
19
- /**
20
- * Structured fix guidance shown under a violation in a blocked-write / blocked-bash report.
21
- *
22
- * A rule authors its user-facing text once here: a required `violation` (the "what's wrong"
23
- * line — the rule-level default for the `→` line; a dynamic per-occurrence `Violation.message`
24
- * overrides it), a `mainMessage` (fix prose, or a lead-in to the options), an optional list of
25
- * genuinely distinct `fixOptions`, and — for the disable-able code-style rules — a framework-
26
- * owned `escape`.
27
- *
28
- * The framework (report.ts / `formatFixOptions`) — not the rule author — owns the "Fix Option N:"
29
- * numbering, the "(preferred)" tag, and the escape/`disableAllowed` rendering. So a multi-line
30
- * message can never be mis-split into fake options, and authors never hand-write those labels.
31
- *
32
- * `Option` is NOT defined here: it lives in `@webpieces/rules-config` (`fix-option.ts`) because
33
- * `RuleFailError` — thrown by BOTH engines — carries the same class. One cure shape, one definition,
34
- * one import path. Import it from `@webpieces/rules-config`, never from this module.
35
- */
36
- class FixHint {
37
- /** Required: the "what's wrong" line (rule-level default for the `→` line). */
38
- violation;
39
- /** Required (may be ''): fix prose, or a lead-in to the options. Multi-line ok. */
40
- mainMessage;
41
- /** Real fixes only — NEVER the disable escape (that is `escape`). */
42
- fixOptions;
43
- /** Present only for disable-able rules; absent for guards. */
44
- escape;
45
- constructor(violation, mainMessage, fixOptions = [], escape) {
46
- this.violation = violation;
47
- this.mainMessage = mainMessage;
48
- this.fixOptions = fixOptions;
49
- this.escape = escape;
50
- }
51
- }
52
- exports.FixHint = FixHint;
53
- //# sourceMappingURL=fix-hint.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fix-hint.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/core/fix-hint.ts"],"names":[],"mappings":";;;AAEA;;;;;GAKG;AACH,MAAa,aAAa;IACb,OAAO,CAAU;IACjB,OAAO,CAAS;IAEzB,YAAY,OAAgB,EAAE,OAAe;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IAC3B,CAAC;CACJ;AARD,sCAQC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,OAAO;IAChB,+EAA+E;IACtE,SAAS,CAAS;IAC3B,mFAAmF;IAC1E,WAAW,CAAS;IAC7B,qEAAqE;IAC5D,UAAU,CAAoB;IACvC,8DAA8D;IACrD,MAAM,CAAiB;IAEhC,YACI,SAAiB,EACjB,WAAmB,EACnB,aAAgC,EAAE,EAClC,MAAsB;QAEtB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACzB,CAAC;CACJ;AArBD,0BAqBC","sourcesContent":["import { Option } from '@webpieces/rules-config';\n\n/**\n * Framework-owned `// webpieces-disable` escape hatch for a rule, gated by the team's\n * `disableAllowed` config (default true). `comment` is the exact suppress syntax to show\n * (usually `// webpieces-disable <rule> -- <reason>`; max-file-lines uses the eslint form).\n * When `allowed` is false the framework prints a \"must be followed\" line instead of the escape.\n */\nexport class DisableEscape {\n readonly allowed: boolean;\n readonly comment: string;\n\n constructor(allowed: boolean, comment: string) {\n this.allowed = allowed;\n this.comment = comment;\n }\n}\n\n/**\n * Structured fix guidance shown under a violation in a blocked-write / blocked-bash report.\n *\n * A rule authors its user-facing text once here: a required `violation` (the \"what's wrong\"\n * line — the rule-level default for the `→` line; a dynamic per-occurrence `Violation.message`\n * overrides it), a `mainMessage` (fix prose, or a lead-in to the options), an optional list of\n * genuinely distinct `fixOptions`, and — for the disable-able code-style rules — a framework-\n * owned `escape`.\n *\n * The framework (report.ts / `formatFixOptions`) — not the rule author — owns the \"Fix Option N:\"\n * numbering, the \"(preferred)\" tag, and the escape/`disableAllowed` rendering. So a multi-line\n * message can never be mis-split into fake options, and authors never hand-write those labels.\n *\n * `Option` is NOT defined here: it lives in `@webpieces/rules-config` (`fix-option.ts`) because\n * `RuleFailError` — thrown by BOTH engines — carries the same class. One cure shape, one definition,\n * one import path. Import it from `@webpieces/rules-config`, never from this module.\n */\nexport class FixHint {\n /** Required: the \"what's wrong\" line (rule-level default for the `→` line). */\n readonly violation: string;\n /** Required (may be ''): fix prose, or a lead-in to the options. Multi-line ok. */\n readonly mainMessage: string;\n /** Real fixes only — NEVER the disable escape (that is `escape`). */\n readonly fixOptions: readonly Option[];\n /** Present only for disable-able rules; absent for guards. */\n readonly escape?: DisableEscape;\n\n constructor(\n violation: string,\n mainMessage: string,\n fixOptions: readonly Option[] = [],\n escape?: DisableEscape,\n ) {\n this.violation = violation;\n this.mainMessage = mainMessage;\n this.fixOptions = fixOptions;\n this.escape = escape;\n }\n}\n"]}
@@ -1,32 +0,0 @@
1
- import { EffectiveTree } from './effective-tree';
2
- import { BlockedResult } from './types';
3
- /**
4
- * L1 row 5: git/gh commands must run from the repo root of the tree they act on, where the guards can
5
- * reason about git state coherently. guards/L1-location.md carries the table and the use cases; change
6
- * this predicate and that file is stale until you update it.
7
- *
8
- * ONE variable decides it: `tree.effectiveCwd` — the directory the command actually runs in, which is
9
- * the shell's cwd unless the command leads with `cd <dir> &&`. Root or not-root, nothing else.
10
- *
11
- * It used to be `shellAtRoot || cdsToRoot`, two variables OR'd, and that produced opposite verdicts for
12
- * the same destination: `git status` with the shell in packages/http/ was BLOCKED, while
13
- * `cd packages/http && git status` from the root was ALLOWED, because shellAtRoot short-circuited before
14
- * the destination was ever considered. An agent that cd's INTO a subdir has the same broken mental model
15
- * as one stranded there, so it gets the same answer now.
16
- *
17
- * The remedy is ONE runnable line, `cd <root> && <the work>`, not "cd first, then re-run" — that advice
18
- * made this guard print the very command it had just rejected, and a `cd` is unreliable in both
19
- * directions (INTO this repo it sticks; OUT of it the harness resets it).
20
- *
21
- * It goes through remedyAtRoot(), NOT bare atRoot(), and that is load-bearing: A REMEDY MUST SATISFY THE
22
- * PREDICATE THAT PRINTED IT. Prefixing `cd '<root>' &&` onto a command already leading with
23
- * `cd <elsewhere> &&` left effectiveCwd in `<elsewhere>`, so the identical block fired on the remedy with
24
- * the prefix doubled, then tripled. remedyAtRoot REPLACES the leading `cd` run instead, and
25
- * effective-tree.spec.ts asserts that property for every L1 remedy, not just this one.
26
- */
27
- export declare class ForceToRootGuard {
28
- private readonly resolver;
29
- /** The deny report, or null to allow. */
30
- block(command: string, tree: EffectiveTree, isGitOrGh: boolean): string | null;
31
- }
32
- export declare function gitFromSubdirBlock(command: string, tree: EffectiveTree, isGitOrGh: boolean): BlockedResult | null;