@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,43 +0,0 @@
1
- import { CommandScanner } from '../command-scan';
2
- /**
3
- * The branch a checkout/switch lands on, and whether that command CREATES it.
4
- *
5
- * `created` is load-bearing rather than cosmetic: `git checkout -b x origin/main` lands on a branch
6
- * that is current by construction (nothing to be stale about), whereas landing on an EXISTING local
7
- * `main` is exactly the stale-checkout hazard. Data-only, so a class (per CLAUDE.md).
8
- */
9
- export declare class BranchSwitch {
10
- branch: string;
11
- created: boolean;
12
- constructor(branch: string, created: boolean);
13
- }
14
- export declare class BranchSwitchScan {
15
- private readonly scanner;
16
- constructor(scanner?: CommandScanner);
17
- /**
18
- * The branch this segment switches to, or null when the segment does not land on a branch at all:
19
- * a different command, no target word, `git checkout -` (the previous branch — unknowable here),
20
- * or anything after `--` (which ends option parsing, making the rest PATHSPECS, so
21
- * `git checkout -- main` restores a FILE named main and moves no branch).
22
- *
23
- * Flag-tolerant by construction: every leading flag is walked past, so `-q`, `--quiet`,
24
- * `--no-track`, `--detach` and friends change nothing about which word is the target.
25
- */
26
- targetOf(segment: string): BranchSwitch | null;
27
- /**
28
- * True only for landing on an EXISTING branch named `main` — the form that can hand you a stale
29
- * tree, and the form `git checkout main && git pull origin main` uses. `-b`/`-B`/`-c`/`-C` are
30
- * excluded because they create the branch here and now.
31
- *
32
- * This scan reads raw GIT, and it has to keep doing so even though the workflow messages now
33
- * prescribe `pnpm wp-sync-main` instead: what the guards recommend is not what an agent
34
- * necessarily types, the raw pair is still allowed and is still the L0 recovery cure, and a scan
35
- * that stopped recognising it would stop catching the bare `git checkout main` it exists to catch.
36
- */
37
- landsOnExistingMain(segment: string): boolean;
38
- /** The same question for a target already parsed (switchesIn). One spelling, two entry shapes. */
39
- isExistingMain(target: BranchSwitch): boolean;
40
- /** Every segment of a whole command that lands on a branch, in order. */
41
- switchesIn(command: string): readonly BranchSwitch[];
42
- private createdBranch;
43
- }
@@ -1,132 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BranchSwitchScan = exports.BranchSwitch = void 0;
4
- const command_scan_1 = require("../command-scan");
5
- /**
6
- * "Which branch does this `git checkout` / `git switch` land me on?" — the ONE place that question is
7
- * answered, for every guard that asks it.
8
- *
9
- * It used to be answered by two regexes in redirect-how-to-merge-main
10
- * (`/git\s+(?:checkout|switch)\s+main\b/` to EXEMPT main, and a negative-lookahead twin to catch a
11
- * feature switch) and by a third, hand-rolled word walk in stale-main-bash-guard. The regex pair
12
- * assumed the branch name is the token immediately after the subcommand, so ONE flag broke it:
13
- *
14
- * git checkout main → exempted (correct)
15
- * git checkout -q main → `main` no longer follows `checkout`, so the exemption MISSED, the
16
- * lookahead concluded the target was not main, and the command was
17
- * blocked with "this switches to a feature branch and then pulls main
18
- * into it" — the exact opposite of what it does.
19
- *
20
- * That block landed on the cure stale-main-bash-guard itself prescribes, so the two guards
21
- * contradicted each other and a human had to route around both to update main. The fix is not a
22
- * cleverer regex: it is to TOKENIZE (CommandScanner already does the hard part) and walk the flags,
23
- * which is also why it must exist once rather than three times.
24
- *
25
- * Deliberately NOT "does the string contain main" — over-matching here is worse than the original
26
- * bug, because `git checkout -b feature/main-thing` and `git checkout -- main.ts` would then read as
27
- * "switching to main" and be EXEMPTED from a guard whose whole job is to catch a feature-branch pull.
28
- */
29
- const CREATE_FLAGS = new Set(['-b', '-B', '-c', '-C', '--orphan']);
30
- // Non-creating flags that consume the FOLLOWING token, so its value is never mistaken for the target.
31
- const FLAGS_WITH_VALUE = new Set(['--conflict', '--pathspec-from-file', '--start-point']);
32
- /**
33
- * The branch a checkout/switch lands on, and whether that command CREATES it.
34
- *
35
- * `created` is load-bearing rather than cosmetic: `git checkout -b x origin/main` lands on a branch
36
- * that is current by construction (nothing to be stale about), whereas landing on an EXISTING local
37
- * `main` is exactly the stale-checkout hazard. Data-only, so a class (per CLAUDE.md).
38
- */
39
- class BranchSwitch {
40
- branch;
41
- created;
42
- constructor(branch, created) {
43
- this.branch = branch;
44
- this.created = created;
45
- }
46
- }
47
- exports.BranchSwitch = BranchSwitch;
48
- class BranchSwitchScan {
49
- scanner;
50
- constructor(scanner = new command_scan_1.CommandScanner()) {
51
- this.scanner = scanner;
52
- }
53
- /**
54
- * The branch this segment switches to, or null when the segment does not land on a branch at all:
55
- * a different command, no target word, `git checkout -` (the previous branch — unknowable here),
56
- * or anything after `--` (which ends option parsing, making the rest PATHSPECS, so
57
- * `git checkout -- main` restores a FILE named main and moves no branch).
58
- *
59
- * Flag-tolerant by construction: every leading flag is walked past, so `-q`, `--quiet`,
60
- * `--no-track`, `--detach` and friends change nothing about which word is the target.
61
- */
62
- targetOf(segment) {
63
- const subcommand = this.scanner.gitSubcommand(segment);
64
- if (subcommand !== 'checkout' && subcommand !== 'switch')
65
- return null;
66
- const words = this.scanner.words(segment);
67
- const args = words.slice(words.indexOf(subcommand) + 1);
68
- for (let i = 0; i < args.length; i++) {
69
- const word = args[i];
70
- if (word === '--')
71
- return null;
72
- if (word === '-')
73
- return null;
74
- const created = this.createdBranch(args, i);
75
- if (created !== null)
76
- return created;
77
- if (FLAGS_WITH_VALUE.has(word)) {
78
- i++;
79
- continue;
80
- }
81
- if (word.startsWith('-'))
82
- continue;
83
- return new BranchSwitch(word, false);
84
- }
85
- return null;
86
- }
87
- /**
88
- * True only for landing on an EXISTING branch named `main` — the form that can hand you a stale
89
- * tree, and the form `git checkout main && git pull origin main` uses. `-b`/`-B`/`-c`/`-C` are
90
- * excluded because they create the branch here and now.
91
- *
92
- * This scan reads raw GIT, and it has to keep doing so even though the workflow messages now
93
- * prescribe `pnpm wp-sync-main` instead: what the guards recommend is not what an agent
94
- * necessarily types, the raw pair is still allowed and is still the L0 recovery cure, and a scan
95
- * that stopped recognising it would stop catching the bare `git checkout main` it exists to catch.
96
- */
97
- landsOnExistingMain(segment) {
98
- const target = this.targetOf(segment);
99
- return target !== null && this.isExistingMain(target);
100
- }
101
- /** The same question for a target already parsed (switchesIn). One spelling, two entry shapes. */
102
- isExistingMain(target) {
103
- return target.branch === 'main' && !target.created;
104
- }
105
- /** Every segment of a whole command that lands on a branch, in order. */
106
- switchesIn(command) {
107
- const found = [];
108
- for (const segment of this.scanner.commandSegments(command)) {
109
- const target = this.targetOf(segment);
110
- if (target !== null)
111
- found.push(target);
112
- }
113
- return found;
114
- }
115
- // `-b <name>` / `--orphan=<name>` — the new branch's name, or null when this word creates nothing.
116
- createdBranch(args, i) {
117
- const word = args[i];
118
- if (CREATE_FLAGS.has(word)) {
119
- const name = args[i + 1];
120
- if (name === undefined || name.startsWith('-'))
121
- return null;
122
- return new BranchSwitch(name, true);
123
- }
124
- const equals = word.indexOf('=');
125
- if (equals > 0 && CREATE_FLAGS.has(word.slice(0, equals))) {
126
- return new BranchSwitch(word.slice(equals + 1), true);
127
- }
128
- return null;
129
- }
130
- }
131
- exports.BranchSwitchScan = BranchSwitchScan;
132
- //# sourceMappingURL=branch-switch-scan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"branch-switch-scan.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/branch-switch-scan.ts"],"names":[],"mappings":";;;AAAA,kDAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC;AAExF,sGAAsG;AACtG,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAC,CAAC,YAAY,EAAE,sBAAsB,EAAE,eAAe,CAAC,CAAC,CAAC;AAE/G;;;;;;GAMG;AACH,MAAa,YAAY;IACrB,MAAM,CAAS;IACf,OA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G,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACjC,IAAI,MAAM,GAAG,CAAC,IAAI,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC;YACxD,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ;AA5ED,4CA4EC","sourcesContent":["import { CommandScanner } from '../command-scan';\n\n/**\n * \"Which branch does this `git checkout` / `git switch` land me on?\" — the ONE place that question is\n * answered, for every guard that asks it.\n *\n * It used to be answered by two regexes in redirect-how-to-merge-main\n * (`/git\\s+(?:checkout|switch)\\s+main\\b/` to EXEMPT main, and a negative-lookahead twin to catch a\n * feature switch) and by a third, hand-rolled word walk in stale-main-bash-guard. The regex pair\n * assumed the branch name is the token immediately after the subcommand, so ONE flag broke it:\n *\n * git checkout main → exempted (correct)\n * git checkout -q main → `main` no longer follows `checkout`, so the exemption MISSED, the\n * lookahead concluded the target was not main, and the command was\n * blocked with \"this switches to a feature branch and then pulls main\n * into it\" — the exact opposite of what it does.\n *\n * That block landed on the cure stale-main-bash-guard itself prescribes, so the two guards\n * contradicted each other and a human had to route around both to update main. The fix is not a\n * cleverer regex: it is to TOKENIZE (CommandScanner already does the hard part) and walk the flags,\n * which is also why it must exist once rather than three times.\n *\n * Deliberately NOT \"does the string contain main\" — over-matching here is worse than the original\n * bug, because `git checkout -b feature/main-thing` and `git checkout -- main.ts` would then read as\n * \"switching to main\" and be EXEMPTED from a guard whose whole job is to catch a feature-branch pull.\n */\nconst CREATE_FLAGS: ReadonlySet<string> = new Set(['-b', '-B', '-c', '-C', '--orphan']);\n\n// Non-creating flags that consume the FOLLOWING token, so its value is never mistaken for the target.\nconst FLAGS_WITH_VALUE: ReadonlySet<string> = new Set(['--conflict', '--pathspec-from-file', '--start-point']);\n\n/**\n * The branch a checkout/switch lands on, and whether that command CREATES it.\n *\n * `created` is load-bearing rather than cosmetic: `git checkout -b x origin/main` lands on a branch\n * that is current by construction (nothing to be stale about), whereas landing on an EXISTING local\n * `main` is exactly the stale-checkout hazard. Data-only, so a class (per CLAUDE.md).\n */\nexport class BranchSwitch {\n branch: string;\n created: boolean;\n\n constructor(branch: string, created: boolean) {\n this.branch = branch;\n this.created = created;\n }\n}\n\nexport class BranchSwitchScan {\n constructor(private readonly scanner: CommandScanner = new CommandScanner()) {}\n\n /**\n * The branch this segment switches to, or null when the segment does not land on a branch at all:\n * a different command, no target word, `git checkout -` (the previous branch — unknowable here),\n * or anything after `--` (which ends option parsing, making the rest PATHSPECS, so\n * `git checkout -- main` restores a FILE named main and moves no branch).\n *\n * Flag-tolerant by construction: every leading flag is walked past, so `-q`, `--quiet`,\n * `--no-track`, `--detach` and friends change nothing about which word is the target.\n */\n targetOf(segment: string): BranchSwitch | null {\n const subcommand = this.scanner.gitSubcommand(segment);\n if (subcommand !== 'checkout' && subcommand !== 'switch') return null;\n\n const words = this.scanner.words(segment);\n const args = words.slice(words.indexOf(subcommand) + 1);\n\n for (let i = 0; i < args.length; i++) {\n const word = args[i];\n if (word === '--') return null;\n if (word === '-') return null;\n const created = this.createdBranch(args, i);\n if (created !== null) return created;\n if (FLAGS_WITH_VALUE.has(word)) { i++; continue; }\n if (word.startsWith('-')) continue;\n return new BranchSwitch(word, false);\n }\n return null;\n }\n\n /**\n * True only for landing on an EXISTING branch named `main` — the form that can hand you a stale\n * tree, and the form `git checkout main && git pull origin main` uses. `-b`/`-B`/`-c`/`-C` are\n * excluded because they create the branch here and now.\n *\n * This scan reads raw GIT, and it has to keep doing so even though the workflow messages now\n * prescribe `pnpm wp-sync-main` instead: what the guards recommend is not what an agent\n * necessarily types, the raw pair is still allowed and is still the L0 recovery cure, and a scan\n * that stopped recognising it would stop catching the bare `git checkout main` it exists to catch.\n */\n landsOnExistingMain(segment: string): boolean {\n const target = this.targetOf(segment);\n return target !== null && this.isExistingMain(target);\n }\n\n /** The same question for a target already parsed (switchesIn). One spelling, two entry shapes. */\n isExistingMain(target: BranchSwitch): boolean {\n return target.branch === 'main' && !target.created;\n }\n\n /** Every segment of a whole command that lands on a branch, in order. */\n switchesIn(command: string): readonly BranchSwitch[] {\n const found: BranchSwitch[] = [];\n for (const segment of this.scanner.commandSegments(command)) {\n const target = this.targetOf(segment);\n if (target !== null) found.push(target);\n }\n return found;\n }\n\n // `-b <name>` / `--orphan=<name>` — the new branch's name, or null when this word creates nothing.\n private createdBranch(args: readonly string[], i: number): BranchSwitch | null {\n const word = args[i];\n if (CREATE_FLAGS.has(word)) {\n const name = args[i + 1];\n if (name === undefined || name.startsWith('-')) return null;\n return new BranchSwitch(name, true);\n }\n const equals = word.indexOf('=');\n if (equals > 0 && CREATE_FLAGS.has(word.slice(0, equals))) {\n return new BranchSwitch(word.slice(equals + 1), true);\n }\n return null;\n }\n}\n"]}
@@ -1,56 +0,0 @@
1
- import type { BashContext, Violation } from '../types';
2
- import { BashRuleBase, EmptyRuleConfig } from '../rule-base';
3
- import { FixHint } from '../fix-hint';
4
- /**
5
- * Blocks a Bash command that PIPES or REDIRECTS the output of `pnpm wp-build`,
6
- * `pnpm wp-review-upsert-pr` or `pnpm wp-finish-upsert-pr`, and hands back the bare command plus a
7
- * `grep` of the log those commands already write.
8
- *
9
- * ─── The incident, measured ────────────────────────────────────────────────────────────────────────
10
- * The Claude Code harness backgrounds — and then kills — a foreground Bash command that has produced
11
- * no output for 600 seconds. Those three commands defend against that already: the build's output goes
12
- * to a FILE, and the console gets a heartbeat roughly every ten seconds plus a `FullLog :` pointer.
13
- *
14
- * A PIPE deletes that defence. `pnpm wp-review-upsert-pr 2>&1 | tail -50` withholds every byte until
15
- * the writer exits, because that is what `tail` is — so the terminal sees NOTHING for the length of a
16
- * full build, the watchdog fires, and the work is thrown away. The last fleet audit attributed ≥100
17
- * minutes of wall time to those kills across 8 agents, and this repo's primary tree alone holds 85
18
- * piped `wp-*` calls, 42 of them on a build-running command (`wp-review-upsert-pr` 22,
19
- * `wp-finish-upsert-pr` 17, `wp-build` 3).
20
- *
21
- * A `> file` redirect is the same silence, and additionally writes a second copy of a log the command
22
- * already wrote.
23
- *
24
- * ─── Why the ORDER of the fix matters, and why this half came second ───────────────────────────────
25
- * Agents pipe these commands for a REASON: stage ② and stage ③ used to print everything they did. So
26
- * the output was shrunk FIRST — both stages now capture their verbose body to a log and keep only the
27
- * lines an agent must act on (see `StageOutputLog` in @webpieces/pr-gate). Blocking the pipe before
28
- * that would have traded a watchdog kill for a flooded context, and an agent would have routed around
29
- * it with `> file` — which is why the redirect is on the blocklist too.
30
- *
31
- * ─── It acts UNCONDITIONALLY, and has NO config key ────────────────────────────────────────────────
32
- * Like `commit-message-substitution-guard`, and for the same two reasons.
33
- *
34
- * It has no key because a NEW key under `hookGuards` is a key every consumer must ADD or have every
35
- * Bash call blocked on upgrade (fault Y) — that shipped once already, with `whole-repo-build-guard`,
36
- * and took upgrading consumers' shells down for a feature nobody had asked for. Loading here, outside
37
- * the config-driven set, makes the config-sync check structurally unable to see it.
38
- *
39
- * It needs no switch because there is nothing for one to rescue: the cure is available for every
40
- * input, is strictly better than what was blocked, and can never itself match this guard. Running the
41
- * command bare gives you a heartbeat instead of silence and a log you can `grep` any number of times
42
- * instead of a fixed 50 lines you have to re-run a build to change.
43
- */
44
- export declare class BuildOutputPipeGuardRule extends BashRuleBase<EmptyRuleConfig> {
45
- constructor();
46
- private readonly scan;
47
- readonly description: string;
48
- get fixHint(): FixHint;
49
- check(ctx: BashContext): readonly Violation[];
50
- private allow;
51
- private block;
52
- private message;
53
- private what;
54
- private truncate;
55
- private logDecision;
56
- }
@@ -1,120 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildOutputPipeGuardRule = void 0;
4
- const rules_config_1 = require("@webpieces/rules-config");
5
- const types_1 = require("../types");
6
- const rule_base_1 = require("../rule-base");
7
- const fix_hint_1 = require("../fix-hint");
8
- const l0_fault_codes_1 = require("../l0-fault-codes");
9
- const decision_log_1 = require("../decision-log");
10
- const command_scan_1 = require("../command-scan");
11
- const shell_segment_scan_1 = require("./shell-segment-scan");
12
- const build_output_pipe_scan_1 = require("./build-output-pipe-scan");
13
- /**
14
- * Blocks a Bash command that PIPES or REDIRECTS the output of `pnpm wp-build`,
15
- * `pnpm wp-review-upsert-pr` or `pnpm wp-finish-upsert-pr`, and hands back the bare command plus a
16
- * `grep` of the log those commands already write.
17
- *
18
- * ─── The incident, measured ────────────────────────────────────────────────────────────────────────
19
- * The Claude Code harness backgrounds — and then kills — a foreground Bash command that has produced
20
- * no output for 600 seconds. Those three commands defend against that already: the build's output goes
21
- * to a FILE, and the console gets a heartbeat roughly every ten seconds plus a `FullLog :` pointer.
22
- *
23
- * A PIPE deletes that defence. `pnpm wp-review-upsert-pr 2>&1 | tail -50` withholds every byte until
24
- * the writer exits, because that is what `tail` is — so the terminal sees NOTHING for the length of a
25
- * full build, the watchdog fires, and the work is thrown away. The last fleet audit attributed ≥100
26
- * minutes of wall time to those kills across 8 agents, and this repo's primary tree alone holds 85
27
- * piped `wp-*` calls, 42 of them on a build-running command (`wp-review-upsert-pr` 22,
28
- * `wp-finish-upsert-pr` 17, `wp-build` 3).
29
- *
30
- * A `> file` redirect is the same silence, and additionally writes a second copy of a log the command
31
- * already wrote.
32
- *
33
- * ─── Why the ORDER of the fix matters, and why this half came second ───────────────────────────────
34
- * Agents pipe these commands for a REASON: stage ② and stage ③ used to print everything they did. So
35
- * the output was shrunk FIRST — both stages now capture their verbose body to a log and keep only the
36
- * lines an agent must act on (see `StageOutputLog` in @webpieces/pr-gate). Blocking the pipe before
37
- * that would have traded a watchdog kill for a flooded context, and an agent would have routed around
38
- * it with `> file` — which is why the redirect is on the blocklist too.
39
- *
40
- * ─── It acts UNCONDITIONALLY, and has NO config key ────────────────────────────────────────────────
41
- * Like `commit-message-substitution-guard`, and for the same two reasons.
42
- *
43
- * It has no key because a NEW key under `hookGuards` is a key every consumer must ADD or have every
44
- * Bash call blocked on upgrade (fault Y) — that shipped once already, with `whole-repo-build-guard`,
45
- * and took upgrading consumers' shells down for a feature nobody had asked for. Loading here, outside
46
- * the config-driven set, makes the config-sync check structurally unable to see it.
47
- *
48
- * It needs no switch because there is nothing for one to rescue: the cure is available for every
49
- * input, is strictly better than what was blocked, and can never itself match this guard. Running the
50
- * command bare gives you a heartbeat instead of silence and a log you can `grep` any number of times
51
- * instead of a fixed 50 lines you have to re-run a build to change.
52
- */
53
- class BuildOutputPipeGuardRule extends rule_base_1.BashRuleBase {
54
- constructor() {
55
- // configKey === name and is DELIBERATELY not a real webpieces.config.json key — see the class
56
- // docstring on fault Y.
57
- super(new rule_base_1.EmptyRuleConfig(), 'build-output-pipe-guard', 'build-output-pipe-guard');
58
- }
59
- scan = new build_output_pipe_scan_1.BuildOutputPipeScan(new command_scan_1.CommandScanner(), new shell_segment_scan_1.ShellSegmentScan());
60
- description = 'Block piping or redirecting the output of pnpm wp-build / wp-review-upsert-pr / ' +
61
- 'wp-finish-upsert-pr — a pipe withholds their heartbeat until exit, so the 600s watchdog kills ' +
62
- 'the build — and name the bare command plus a grep of the log they already write.';
63
- get fixHint() {
64
- return new fix_hint_1.FixHint('Piping one of these commands hides the heartbeat that proves it is alive, and the harness ' +
65
- 'kills a command that has printed nothing for 600 seconds — after a full build has run.', 'Their output is ALREADY in a file. Run the command bare and read the file it names:', [
66
- // Names NO command. `fixHint` is static per-rule and cannot see which command was
67
- // actually piped, while `message(hit)` above already prints that exact command bare —
68
- // so hardcoding one here spelled `wp-build` at somebody who piped `wp-review-upsert-pr`,
69
- // which is a cure that does not match the block. One statement of the command, in the
70
- // one place that knows it.
71
- new rules_config_1.Option('Re-run the command named above with nothing after it — no pipe, no redirect.\n' +
72
- 'The console stays short — a size heartbeat, then the result and a "FullLog : <path>" line.', true),
73
- new rules_config_1.Option('Then read as much or as little of that log as you like, as many times as you like:\n' +
74
- ' grep -n error "<the FullLog path it printed>"\n' +
75
- ' tail -50 "<the FullLog path it printed>"\n' +
76
- 'Use the path from THIS run, never one typed from memory — a stale relative path ' +
77
- 'greps nothing, which reads exactly like a clean build.'),
78
- new rules_config_1.Option('The previous run is still on disk as "<that path>.bak", so comparing two runs ' +
79
- 'needs no third one.'),
80
- ]);
81
- }
82
- check(ctx) {
83
- // Blocklist-shaped, so match on commandCode: stripping heredocs and quoted prose can only ever
84
- // block LESS, and this repo's own commit messages and docs are full of these command names.
85
- const hit = this.scan.firstHit(ctx.commandCode);
86
- if (hit === null)
87
- return this.allow(ctx);
88
- return this.block(ctx, hit);
89
- }
90
- allow(ctx) {
91
- this.logDecision(ctx, 'ALLOW', 'output-not-bounded');
92
- return [];
93
- }
94
- block(ctx, hit) {
95
- // BLOCK_AI_CURE: the cure is the SAME command with less typing, which the agent runs itself.
96
- this.logDecision(ctx, 'BLOCK_AI_CURE', `${hit.command}-${hit.shape}`);
97
- return [new types_1.Violation(1, this.truncate(ctx.command), this.message(hit))];
98
- }
99
- // Short on purpose: it is read mid-task by an agent that needs the ONE next move.
100
- message(hit) {
101
- return `Blocked: ${this.what(hit)} \`${hit.command}\`. That command already writes its full output `
102
- + 'to a log file and prints a heartbeat while it runs — and bounding it withholds every byte '
103
- + 'until the command exits, so the harness sees a silent command and KILLS it at 600s, after '
104
- + 'the whole build has run.\n\n'
105
- + ` pnpm ${hit.command}\n\n`
106
- + 'Then grep the "FullLog : <path>" it prints. The previous run is kept beside it as `.bak`.';
107
- }
108
- what(hit) {
109
- return hit.shape === build_output_pipe_scan_1.BOUND_BY_PIPE ? 'you piped' : 'you redirected the output of';
110
- }
111
- truncate(s) {
112
- const MAX = 120;
113
- return s.length <= MAX ? s : s.slice(0, MAX) + '…';
114
- }
115
- logDecision(ctx, verdict, reason) {
116
- (0, decision_log_1.logGuardDecision)(ctx.workspaceRoot, new decision_log_1.GuardDecision('build-output-pipe-guard', 'Bash', ctx.command, '-', verdict, reason, '-', l0_fault_codes_1.L0_FAULT_NONE, decision_log_1.MATRIX_L2_UNROWED));
117
- }
118
- }
119
- exports.BuildOutputPipeGuardRule = BuildOutputPipeGuardRule;
120
- //# sourceMappingURL=build-output-pipe-guard.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-output-pipe-guard.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/build-output-pipe-guard.ts"],"names":[],"mappings":";;;AAAA,0DAAiD;AAGjD,oCAA0C;AAC1C,4CAA6D;AAC7D,0CAAsC;AACtC,sDAAkD;AAClD,kDAA8F;AAC9F,kDAAiD;AACjD,6DAAwD;AACxD,qEAEkC;AAElC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuCG;AACH,MAAa,wBAAyB,SAAQ,wBAA6B;IACvE;QACI,8FAA8F;QAC9F,wBAAwB;QACxB,KAAK,CAAC,IAAI,2BAAe,EAAE,EAAE,yBAAyB,EAAE,yBAAyB,CAAC,CAAC;IACvF,CAAC;IAEgB,IAAI,GAAG,IAAI,4CAAmB,CAAC,IAAI,6BAAc,EAAE,EAAE,IAAI,qCAAgB,EAAE,CAAC,CAAC;IAErF,WAAW,GAChB,kFAAkF;QAClF,gGAAgG;QAChG,kFAAkF,CAAC;IAEvF,IAAI,OAAO;QACP,OAAO,IAAI,kBAAO,CACd,4FAA4F;YAC5F,wFAAwF,EACxF,qFAAqF,EACrF;YACI,kFAAkF;YAClF,sFAAsF;YACtF,yFAAyF;YACzF,sFAAsF;YACtF,2BAA2B;YAC3B,IAAI,qBAAM,CACN,gFAAgF;gBAChF,4FAA4F,EAC5F,IAAI,CAAC;YACT,IAAI,qBAAM,CACN,sFAAsF;gBACtF,qDAAqD;gBACrD,gDAAgD;gBAChD,kFAAkF;gBAClF,wDAAwD,CAAC;YAC7D,IAAI,qBAAM,CACN,gFAAgF;gBAChF,qBAAqB,CAAC;SAC7B,CACJ,CAAC;IACN,CAAC;IAED,KAAK,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AO,CAAC,CAAC,MAAM,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;IACvD,CAAC;IAEO,WAAW,CAAC,GAAgB,EAAE,OAAgB,EAAE,MAAc;QAClE,IAAA,+BAAgB,EACZ,GAAG,CAAC,aAAa,EACjB,IAAI,4BAAa,CACb,yBAAyB,EAAE,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EACpE,GAAG,EAAE,8BAAa,EAAE,gCAAiB,CACxC,CACJ,CAAC;IACN,CAAC;CACJ;AAzFD,4DAyFC","sourcesContent":["import { Option } from '@webpieces/rules-config';\n\nimport type { BashContext, Violation } from '../types';\nimport { Violation as V } from '../types';\nimport { BashRuleBase, EmptyRuleConfig } from '../rule-base';\nimport { FixHint } from '../fix-hint';\nimport { L0_FAULT_NONE } from '../l0-fault-codes';\nimport { logGuardDecision, GuardDecision, Verdict, MATRIX_L2_UNROWED } from '../decision-log';\nimport { CommandScanner } from '../command-scan';\nimport { ShellSegmentScan } from './shell-segment-scan';\nimport {\n BuildOutputPipeScan, BoundedOutputHit, BOUND_BY_PIPE,\n} from './build-output-pipe-scan';\n\n/**\n * Blocks a Bash command that PIPES or REDIRECTS the output of `pnpm wp-build`,\n * `pnpm wp-review-upsert-pr` or `pnpm wp-finish-upsert-pr`, and hands back the bare command plus a\n * `grep` of the log those commands already write.\n *\n * ─── The incident, measured ────────────────────────────────────────────────────────────────────────\n * The Claude Code harness backgrounds — and then kills — a foreground Bash command that has produced\n * no output for 600 seconds. Those three commands defend against that already: the build's output goes\n * to a FILE, and the console gets a heartbeat roughly every ten seconds plus a `FullLog :` pointer.\n *\n * A PIPE deletes that defence. `pnpm wp-review-upsert-pr 2>&1 | tail -50` withholds every byte until\n * the writer exits, because that is what `tail` is — so the terminal sees NOTHING for the length of a\n * full build, the watchdog fires, and the work is thrown away. The last fleet audit attributed ≥100\n * minutes of wall time to those kills across 8 agents, and this repo's primary tree alone holds 85\n * piped `wp-*` calls, 42 of them on a build-running command (`wp-review-upsert-pr` 22,\n * `wp-finish-upsert-pr` 17, `wp-build` 3).\n *\n * A `> file` redirect is the same silence, and additionally writes a second copy of a log the command\n * already wrote.\n *\n * ─── Why the ORDER of the fix matters, and why this half came second ───────────────────────────────\n * Agents pipe these commands for a REASON: stage ② and stage ③ used to print everything they did. So\n * the output was shrunk FIRST — both stages now capture their verbose body to a log and keep only the\n * lines an agent must act on (see `StageOutputLog` in @webpieces/pr-gate). Blocking the pipe before\n * that would have traded a watchdog kill for a flooded context, and an agent would have routed around\n * it with `> file` — which is why the redirect is on the blocklist too.\n *\n * ─── It acts UNCONDITIONALLY, and has NO config key ────────────────────────────────────────────────\n * Like `commit-message-substitution-guard`, and for the same two reasons.\n *\n * It has no key because a NEW key under `hookGuards` is a key every consumer must ADD or have every\n * Bash call blocked on upgrade (fault Y) — that shipped once already, with `whole-repo-build-guard`,\n * and took upgrading consumers' shells down for a feature nobody had asked for. Loading here, outside\n * the config-driven set, makes the config-sync check structurally unable to see it.\n *\n * It needs no switch because there is nothing for one to rescue: the cure is available for every\n * input, is strictly better than what was blocked, and can never itself match this guard. Running the\n * command bare gives you a heartbeat instead of silence and a log you can `grep` any number of times\n * instead of a fixed 50 lines you have to re-run a build to change.\n */\nexport class BuildOutputPipeGuardRule extends BashRuleBase<EmptyRuleConfig> {\n constructor() {\n // configKey === name and is DELIBERATELY not a real webpieces.config.json key — see the class\n // docstring on fault Y.\n super(new EmptyRuleConfig(), 'build-output-pipe-guard', 'build-output-pipe-guard');\n }\n\n private readonly scan = new BuildOutputPipeScan(new CommandScanner(), new ShellSegmentScan());\n\n readonly description =\n 'Block piping or redirecting the output of pnpm wp-build / wp-review-upsert-pr / ' +\n 'wp-finish-upsert-pr — a pipe withholds their heartbeat until exit, so the 600s watchdog kills ' +\n 'the build — and name the bare command plus a grep of the log they already write.';\n\n get fixHint(): FixHint {\n return new FixHint(\n 'Piping one of these commands hides the heartbeat that proves it is alive, and the harness ' +\n 'kills a command that has printed nothing for 600 seconds — after a full build has run.',\n 'Their output is ALREADY in a file. Run the command bare and read the file it names:',\n [\n // Names NO command. `fixHint` is static per-rule and cannot see which command was\n // actually piped, while `message(hit)` above already prints that exact command bare —\n // so hardcoding one here spelled `wp-build` at somebody who piped `wp-review-upsert-pr`,\n // which is a cure that does not match the block. One statement of the command, in the\n // one place that knows it.\n new Option(\n 'Re-run the command named above with nothing after it — no pipe, no redirect.\\n' +\n 'The console stays short — a size heartbeat, then the result and a \"FullLog : <path>\" line.',\n true),\n new Option(\n 'Then read as much or as little of that log as you like, as many times as you like:\\n' +\n ' grep -n error \"<the FullLog path it printed>\"\\n' +\n ' tail -50 \"<the FullLog path it printed>\"\\n' +\n 'Use the path from THIS run, never one typed from memory — a stale relative path ' +\n 'greps nothing, which reads exactly like a clean build.'),\n new Option(\n 'The previous run is still on disk as \"<that path>.bak\", so comparing two runs ' +\n 'needs no third one.'),\n ],\n );\n }\n\n check(ctx: BashContext): readonly Violation[] {\n // Blocklist-shaped, so match on commandCode: stripping heredocs and quoted prose can only ever\n // block LESS, and this repo's own commit messages and docs are full of these command names.\n const hit = this.scan.firstHit(ctx.commandCode);\n if (hit === null) return this.allow(ctx);\n return this.block(ctx, hit);\n }\n\n private allow(ctx: BashContext): readonly Violation[] {\n this.logDecision(ctx, 'ALLOW', 'output-not-bounded');\n return [];\n }\n\n private block(ctx: BashContext, hit: BoundedOutputHit): readonly Violation[] {\n // BLOCK_AI_CURE: the cure is the SAME command with less typing, which the agent runs itself.\n this.logDecision(ctx, 'BLOCK_AI_CURE', `${hit.command}-${hit.shape}`);\n return [new V(1, this.truncate(ctx.command), this.message(hit))];\n }\n\n // Short on purpose: it is read mid-task by an agent that needs the ONE next move.\n private message(hit: BoundedOutputHit): string {\n return `Blocked: ${this.what(hit)} \\`${hit.command}\\`. That command already writes its full output `\n + 'to a log file and prints a heartbeat while it runs — and bounding it withholds every byte '\n + 'until the command exits, so the harness sees a silent command and KILLS it at 600s, after '\n + 'the whole build has run.\\n\\n'\n + ` pnpm ${hit.command}\\n\\n`\n + 'Then grep the \"FullLog : <path>\" it prints. The previous run is kept beside it as `.bak`.';\n }\n\n private what(hit: BoundedOutputHit): string {\n return hit.shape === BOUND_BY_PIPE ? 'you piped' : 'you redirected the output of';\n }\n\n private truncate(s: string): string {\n const MAX = 120;\n return s.length <= MAX ? s : s.slice(0, MAX) + '…';\n }\n\n private logDecision(ctx: BashContext, verdict: Verdict, reason: string): void {\n logGuardDecision(\n ctx.workspaceRoot,\n new GuardDecision(\n 'build-output-pipe-guard', 'Bash', ctx.command, '-', verdict, reason,\n '-', L0_FAULT_NONE, MATRIX_L2_UNROWED,\n ),\n );\n }\n}\n"]}
@@ -1,47 +0,0 @@
1
- import { CommandScanner } from '../command-scan';
2
- import { ShellSegmentScan } from './shell-segment-scan';
3
- /**
4
- * Decides the one question `build-output-pipe-guard` asks: does this command BOUND the output of a
5
- * webpieces command that already writes its output to a file?
6
- *
7
- * ─── The three commands, and why only these three ──────────────────────────────────────────────────
8
- * `wp-build`, `wp-review-upsert-pr` and `wp-finish-upsert-pr` are the commands that RUN A BUILD. Each
9
- * one redirects the build's full stdout+stderr to a log file, prints a ~10-second heartbeat while it
10
- * runs, and ends with a `FullLog :` pointer at the file. Nothing else in the `wp-*` family both takes
11
- * minutes and writes a log, so nothing else belongs on this list — a guard that also refused
12
- * `pnpm wp-cleanup | tail` would be refusing something with no cure.
13
- *
14
- * ─── What is a hit ─────────────────────────────────────────────────────────────────────────────────
15
- * BLOCKED a PIPE out of the command — `pnpm wp-build | tail -50`, `… 2>&1 | grep error`, `| tee`.
16
- * A pipe is the measured hazard and it does not depend on WHAT it feeds: the pipeline's
17
- * reader (`tail`, `head`, `grep`, `wc`) withholds every byte until the writer EXITS, so the
18
- * heartbeat never reaches the terminal, the harness sees a command silent for 600 seconds,
19
- * and it kills a full build. Measured in this repo's own call log: 85 piped `wp-*` calls,
20
- * 42 of them on one of these three commands.
21
- * BLOCKED a stdout REDIRECT to a file — `pnpm wp-build > /tmp/out.log`. Same silence, and it also
22
- * makes a SECOND copy of a log the command already wrote.
23
- *
24
- * ALLOWED the bare command, which is the whole cure.
25
- * ALLOWED `2>&1` on its own — it rewires fds and buffers nothing. `ShellSegmentScan.redirectsToFile`
26
- * owns that carve-out, and it is shared rather than re-spelled here.
27
- * ALLOWED every other command, piped or not. This guard is blocklist-shaped and narrow on purpose.
28
- */
29
- /** The commands whose output already goes to a file, so bounding it can only ever lose information. */
30
- export declare const LOGGED_BUILD_COMMANDS: readonly string[];
31
- /** How the output was bounded. The two shapes read differently in a refusal, so they are named. */
32
- export declare const BOUND_BY_PIPE = "pipe";
33
- export declare const BOUND_BY_REDIRECT = "redirect";
34
- /** One bounded invocation: WHICH command, and HOW its output was bounded. Data-only (per CLAUDE.md). */
35
- export declare class BoundedOutputHit {
36
- command: string;
37
- shape: string;
38
- constructor(command: string, shape: string);
39
- }
40
- export declare class BuildOutputPipeScan {
41
- private readonly scanner;
42
- private readonly segments;
43
- constructor(scanner: CommandScanner, segments: ShellSegmentScan);
44
- /** The first bounded logging command in `command`, or null when there is none. */
45
- firstHit(command: string): BoundedOutputHit | null;
46
- private loggingCommandIn;
47
- }
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.BuildOutputPipeScan = exports.BoundedOutputHit = exports.BOUND_BY_REDIRECT = exports.BOUND_BY_PIPE = exports.LOGGED_BUILD_COMMANDS = void 0;
4
- /**
5
- * Decides the one question `build-output-pipe-guard` asks: does this command BOUND the output of a
6
- * webpieces command that already writes its output to a file?
7
- *
8
- * ─── The three commands, and why only these three ──────────────────────────────────────────────────
9
- * `wp-build`, `wp-review-upsert-pr` and `wp-finish-upsert-pr` are the commands that RUN A BUILD. Each
10
- * one redirects the build's full stdout+stderr to a log file, prints a ~10-second heartbeat while it
11
- * runs, and ends with a `FullLog :` pointer at the file. Nothing else in the `wp-*` family both takes
12
- * minutes and writes a log, so nothing else belongs on this list — a guard that also refused
13
- * `pnpm wp-cleanup | tail` would be refusing something with no cure.
14
- *
15
- * ─── What is a hit ─────────────────────────────────────────────────────────────────────────────────
16
- * BLOCKED a PIPE out of the command — `pnpm wp-build | tail -50`, `… 2>&1 | grep error`, `| tee`.
17
- * A pipe is the measured hazard and it does not depend on WHAT it feeds: the pipeline's
18
- * reader (`tail`, `head`, `grep`, `wc`) withholds every byte until the writer EXITS, so the
19
- * heartbeat never reaches the terminal, the harness sees a command silent for 600 seconds,
20
- * and it kills a full build. Measured in this repo's own call log: 85 piped `wp-*` calls,
21
- * 42 of them on one of these three commands.
22
- * BLOCKED a stdout REDIRECT to a file — `pnpm wp-build > /tmp/out.log`. Same silence, and it also
23
- * makes a SECOND copy of a log the command already wrote.
24
- *
25
- * ALLOWED the bare command, which is the whole cure.
26
- * ALLOWED `2>&1` on its own — it rewires fds and buffers nothing. `ShellSegmentScan.redirectsToFile`
27
- * owns that carve-out, and it is shared rather than re-spelled here.
28
- * ALLOWED every other command, piped or not. This guard is blocklist-shaped and narrow on purpose.
29
- */
30
- /** The commands whose output already goes to a file, so bounding it can only ever lose information. */
31
- exports.LOGGED_BUILD_COMMANDS = [
32
- 'wp-build', 'wp-review-upsert-pr', 'wp-finish-upsert-pr',
33
- ];
34
- const LOGGED_SET = new Set(exports.LOGGED_BUILD_COMMANDS);
35
- /** How the output was bounded. The two shapes read differently in a refusal, so they are named. */
36
- exports.BOUND_BY_PIPE = 'pipe';
37
- exports.BOUND_BY_REDIRECT = 'redirect';
38
- /** One bounded invocation: WHICH command, and HOW its output was bounded. Data-only (per CLAUDE.md). */
39
- class BoundedOutputHit {
40
- command;
41
- shape;
42
- constructor(command, shape) {
43
- this.command = command;
44
- this.shape = shape;
45
- }
46
- }
47
- exports.BoundedOutputHit = BoundedOutputHit;
48
- class BuildOutputPipeScan {
49
- scanner;
50
- segments;
51
- constructor(scanner, segments) {
52
- this.scanner = scanner;
53
- this.segments = segments;
54
- }
55
- /** The first bounded logging command in `command`, or null when there is none. */
56
- firstHit(command) {
57
- const parts = this.scanner.segmentsWithJoins(command);
58
- for (let i = 0; i < parts.length; i++) {
59
- const name = this.loggingCommandIn(parts[i]);
60
- if (name === '')
61
- continue;
62
- // The NEXT segment carries the separator that preceded it, so "this segment pipes OUT" is
63
- // "the segment after me was piped into". Splitting on `|` throws that away; CommandSegment
64
- // exists precisely so it does not have to be re-derived here.
65
- if (i + 1 < parts.length && parts[i + 1].join === '|')
66
- return new BoundedOutputHit(name, exports.BOUND_BY_PIPE);
67
- if (this.segments.redirectsToFile(this.scanner.words(parts[i].text))) {
68
- return new BoundedOutputHit(name, exports.BOUND_BY_REDIRECT);
69
- }
70
- }
71
- return null;
72
- }
73
- // The logging command this segment invokes, or '' — `pnpm wp-build`, `npx wp-build` and a bare
74
- // `wp-build` are one command, which is CommandScanner's `runnerStrippedWords` to decide.
75
- loggingCommandIn(segment) {
76
- const words = this.scanner.runnerStrippedWords(segment.text);
77
- if (words.length === 0)
78
- return '';
79
- const program = this.scanner.programName(words[0]);
80
- return LOGGED_SET.has(program) ? program : '';
81
- }
82
- }
83
- exports.BuildOutputPipeScan = BuildOutputPipeScan;
84
- //# sourceMappingURL=build-output-pipe-scan.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"build-output-pipe-scan.js","sourceRoot":"","sources":["../../../../../../../packages/tooling/ai-hook-rules/src/core/rules/build-output-pipe-scan.ts"],"names":[],"mappings":";;;AAGA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,uGAAuG;AAC1F,QAAA,qBAAqB,GAAsB;IACpD,UAAU,EAAE,qBAAqB,EAAE,qBAAqB;CAC3D,CAAC;AAEF,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC,6BAAqB,CAAC,CAAC;AAEvE,mGAAmG;AACtF,QAAA,aAAa,GAAG,MAAM,CAAC;AACvB,QAAA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;IAChB,CAAC;IAED,+FAA+F;IAC/F,yFAAyF;IACjF,gBAAgB,CAAC,OAAuB;QAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC7D,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,EAAE,CAAC;QAClC,MAAM,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACnD,OAAO,UAAU,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;IAClD,CAAC;CACJ;AA/BD,kDA+BC","sourcesContent":["import { CommandScanner, CommandSegment } from '../command-scan';\nimport { ShellSegmentScan } from './shell-segment-scan';\n\n/**\n * Decides the one question `build-output-pipe-guard` asks: does this command BOUND the output of a\n * webpieces command that already writes its output to a file?\n *\n * ─── The three commands, and why only these three ──────────────────────────────────────────────────\n * `wp-build`, `wp-review-upsert-pr` and `wp-finish-upsert-pr` are the commands that RUN A BUILD. Each\n * one redirects the build's full stdout+stderr to a log file, prints a ~10-second heartbeat while it\n * runs, and ends with a `FullLog :` pointer at the file. Nothing else in the `wp-*` family both takes\n * minutes and writes a log, so nothing else belongs on this list — a guard that also refused\n * `pnpm wp-cleanup | tail` would be refusing something with no cure.\n *\n * ─── What is a hit ─────────────────────────────────────────────────────────────────────────────────\n * BLOCKED a PIPE out of the command — `pnpm wp-build | tail -50`, `… 2>&1 | grep error`, `| tee`.\n * A pipe is the measured hazard and it does not depend on WHAT it feeds: the pipeline's\n * reader (`tail`, `head`, `grep`, `wc`) withholds every byte until the writer EXITS, so the\n * heartbeat never reaches the terminal, the harness sees a command silent for 600 seconds,\n * and it kills a full build. Measured in this repo's own call log: 85 piped `wp-*` calls,\n * 42 of them on one of these three commands.\n * BLOCKED a stdout REDIRECT to a file — `pnpm wp-build > /tmp/out.log`. Same silence, and it also\n * makes a SECOND copy of a log the command already wrote.\n *\n * ALLOWED the bare command, which is the whole cure.\n * ALLOWED `2>&1` on its own — it rewires fds and buffers nothing. `ShellSegmentScan.redirectsToFile`\n * owns that carve-out, and it is shared rather than re-spelled here.\n * ALLOWED every other command, piped or not. This guard is blocklist-shaped and narrow on purpose.\n */\n\n/** The commands whose output already goes to a file, so bounding it can only ever lose information. */\nexport const LOGGED_BUILD_COMMANDS: readonly string[] = [\n 'wp-build', 'wp-review-upsert-pr', 'wp-finish-upsert-pr',\n];\n\nconst LOGGED_SET: ReadonlySet<string> = new Set(LOGGED_BUILD_COMMANDS);\n\n/** How the output was bounded. The two shapes read differently in a refusal, so they are named. */\nexport const BOUND_BY_PIPE = 'pipe';\nexport const BOUND_BY_REDIRECT = 'redirect';\n\n/** One bounded invocation: WHICH command, and HOW its output was bounded. Data-only (per CLAUDE.md). */\nexport class BoundedOutputHit {\n command: string;\n shape: string;\n\n constructor(command: string, shape: string) {\n this.command = command;\n this.shape = shape;\n }\n}\n\nexport class BuildOutputPipeScan {\n constructor(\n private readonly scanner: CommandScanner,\n private readonly segments: ShellSegmentScan,\n ) {}\n\n /** The first bounded logging command in `command`, or null when there is none. */\n firstHit(command: string): BoundedOutputHit | null {\n const parts = this.scanner.segmentsWithJoins(command);\n for (let i = 0; i < parts.length; i++) {\n const name = this.loggingCommandIn(parts[i]);\n if (name === '') continue;\n // The NEXT segment carries the separator that preceded it, so \"this segment pipes OUT\" is\n // \"the segment after me was piped into\". Splitting on `|` throws that away; CommandSegment\n // exists precisely so it does not have to be re-derived here.\n if (i + 1 < parts.length && parts[i + 1].join === '|') return new BoundedOutputHit(name, BOUND_BY_PIPE);\n if (this.segments.redirectsToFile(this.scanner.words(parts[i].text))) {\n return new BoundedOutputHit(name, BOUND_BY_REDIRECT);\n }\n }\n return null;\n }\n\n // The logging command this segment invokes, or '' — `pnpm wp-build`, `npx wp-build` and a bare\n // `wp-build` are one command, which is CommandScanner's `runnerStrippedWords` to decide.\n private loggingCommandIn(segment: CommandSegment): string {\n const words = this.scanner.runnerStrippedWords(segment.text);\n if (words.length === 0) return '';\n const program = this.scanner.programName(words[0]);\n return LOGGED_SET.has(program) ? program : '';\n }\n}\n"]}
@@ -1,39 +0,0 @@
1
- import { FixHint } from '../fix-hint';
2
- /**
3
- * What branch-creation-guard says when a CAP is what blocked. TWO SHORT LINES, and never a
4
- * destructive command.
5
- *
6
- * It used to be forty. The branch remedy printed every spared branch with its SHA, PR state, unique
7
- * commit count and prose reason, told the agent to paste that table at the human and ask which may
8
- * go, and then listed the config knobs it must not touch. The human's verdict on that, verbatim:
9
- * "I am tired of AI asking me to cleanup things it can do by itself". They were right twice over —
10
- * the wall of text buried the one actionable line, and the biggest spared group (pre-merge snapshots
11
- * of a branch that still exists) was never a judgement call at all. That group is auto-reaped now
12
- * (see CLASSIFICATION_BACKUP_OF_LIVE), so the remedy is one command.
13
- *
14
- * Everything this class used to say still exists — in `pnpm wp-cleanup`, which recomputes the
15
- * verdicts fresh, archives each branch as an `archive/<date>/<branch>` tag before deleting, logs a
16
- * `recover=` command per removal, refuses the primary clone and the tree it is standing in, never
17
- * passes `--force`, and PROMPTS about anything not provably dead. A guard that duplicates that
18
- * inventory is a second copy to keep in sync and a wall to read before running the command anyway.
19
- * So: name the command, stop talking.
20
- */
21
- export declare class CapRemedies {
22
- /**
23
- * Deliberately takes no cache and quotes no figures. The cache is allowed to be stale by design,
24
- * and a stale table is worse than no table when the reader's next move is `wp-cleanup` — which
25
- * recomputes from scratch — either way.
26
- *
27
- * "ASK THE HUMAN" stays spelled out. Shortening it to a bare "ask" saves two words and loses the
28
- * object of the verb — and the reader is an agent, which can satisfy a bare "ask" by asking
29
- * itself. Every other guard in this codebase says ASK THE HUMAN for the same reason.
30
- */
31
- branchCap(): FixHint;
32
- /**
33
- * Same shape for worktrees, with one extra sentence that is not boilerplate: a worktree whose
34
- * branch has no commits yet is almost always one an agent is working in RIGHT NOW. That is why
35
- * this never emits `git worktree remove` — it once printed a `prune && remove && branch -D` chain
36
- * naming three live worktrees under the words "so no work can be lost".
37
- */
38
- worktreeCap(): FixHint;
39
- }