@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.
- package/README.md +12 -140
- package/package.json +7 -15
- package/src/adapters/hook-app-fixtures.d.ts +1 -1
- package/src/adapters/hook-app-fixtures.js +0 -8
- package/src/adapters/hook-app-fixtures.js.map +1 -1
- package/src/adapters/hook-core.d.ts +1 -21
- package/src/adapters/hook-core.js +22 -341
- package/src/adapters/hook-core.js.map +1 -1
- package/src/core/load-rules.d.ts +4 -39
- package/src/core/load-rules.js +15 -127
- package/src/core/load-rules.js.map +1 -1
- package/src/core/rules/catch-error-pattern.d.ts +3 -3
- package/src/core/rules/catch-error-pattern.js +13 -13
- package/src/core/rules/catch-error-pattern.js.map +1 -1
- package/src/core/rules/index.d.ts +1 -14
- package/src/core/rules/index.js +1 -17
- package/src/core/rules/index.js.map +1 -1
- package/src/core/rules/match-rule.d.ts +3 -3
- package/src/core/rules/match-rule.js +6 -6
- package/src/core/rules/match-rule.js.map +1 -1
- package/src/core/rules/max-file-lines.d.ts +3 -3
- package/src/core/rules/max-file-lines.js +7 -7
- package/src/core/rules/max-file-lines.js.map +1 -1
- package/src/core/rules/no-any-unknown.d.ts +3 -3
- package/src/core/rules/no-any-unknown.js +6 -6
- package/src/core/rules/no-any-unknown.js.map +1 -1
- package/src/core/rules/no-custom-css.d.ts +3 -3
- package/src/core/rules/no-custom-css.js +7 -7
- package/src/core/rules/no-custom-css.js.map +1 -1
- package/src/core/rules/no-destructure.d.ts +3 -3
- package/src/core/rules/no-destructure.js +7 -7
- package/src/core/rules/no-destructure.js.map +1 -1
- package/src/core/rules/no-implicit-any.d.ts +3 -3
- package/src/core/rules/no-implicit-any.js +6 -6
- package/src/core/rules/no-implicit-any.js.map +1 -1
- package/src/core/rules/no-js-files.d.ts +3 -3
- package/src/core/rules/no-js-files.js +6 -6
- package/src/core/rules/no-js-files.js.map +1 -1
- package/src/core/rules/no-process-exit-outside-main.d.ts +3 -3
- package/src/core/rules/no-process-exit-outside-main.js +7 -7
- package/src/core/rules/no-process-exit-outside-main.js.map +1 -1
- package/src/core/rules/no-symbol-di-tokens.d.ts +3 -3
- package/src/core/rules/no-symbol-di-tokens.js +7 -7
- package/src/core/rules/no-symbol-di-tokens.js.map +1 -1
- package/src/core/rules/no-unmanaged-exceptions.d.ts +3 -3
- package/src/core/rules/no-unmanaged-exceptions.js +9 -9
- package/src/core/rules/no-unmanaged-exceptions.js.map +1 -1
- package/src/core/rules/require-return-type.d.ts +3 -3
- package/src/core/rules/require-return-type.js +6 -6
- package/src/core/rules/require-return-type.js.map +1 -1
- package/src/core/rules/throw-cause-required.d.ts +3 -3
- package/src/core/rules/throw-cause-required.js +9 -9
- package/src/core/rules/throw-cause-required.js.map +1 -1
- package/src/core/rules/validate-ts-in-src.d.ts +3 -3
- package/src/core/rules/validate-ts-in-src.js +7 -7
- package/src/core/rules/validate-ts-in-src.js.map +1 -1
- package/src/core/runner.d.ts +10 -19
- package/src/core/runner.js +24 -622
- package/src/core/runner.js.map +1 -1
- package/src/index.d.ts +2 -15
- package/src/index.js +4 -54
- package/src/index.js.map +1 -1
- package/openclaw.plugin.json +0 -15
- package/src/adapters/agent-adapters.d.ts +0 -13
- package/src/adapters/agent-adapters.js +0 -23
- package/src/adapters/agent-adapters.js.map +0 -1
- package/src/adapters/agent-payload.d.ts +0 -48
- package/src/adapters/agent-payload.js +0 -30
- package/src/adapters/agent-payload.js.map +0 -1
- package/src/adapters/agent-response.d.ts +0 -5
- package/src/adapters/agent-response.js +0 -86
- package/src/adapters/agent-response.js.map +0 -1
- package/src/adapters/claude-code-adapter.d.ts +0 -26
- package/src/adapters/claude-code-adapter.js +0 -69
- package/src/adapters/claude-code-adapter.js.map +0 -1
- package/src/adapters/codex-adapter.d.ts +0 -19
- package/src/adapters/codex-adapter.js +0 -48
- package/src/adapters/codex-adapter.js.map +0 -1
- package/src/adapters/codex-subagent-guard.d.ts +0 -45
- package/src/adapters/codex-subagent-guard.js +0 -88
- package/src/adapters/codex-subagent-guard.js.map +0 -1
- package/src/adapters/detect-ai.d.ts +0 -70
- package/src/adapters/detect-ai.js +0 -82
- package/src/adapters/detect-ai.js.map +0 -1
- package/src/adapters/guards-hook.d.ts +0 -3
- package/src/adapters/guards-hook.js +0 -30
- package/src/adapters/guards-hook.js.map +0 -1
- package/src/adapters/openclaw-plugin.d.ts +0 -14
- package/src/adapters/openclaw-plugin.js +0 -87
- package/src/adapters/openclaw-plugin.js.map +0 -1
- package/src/adapters/review-identity-stamper.d.ts +0 -20
- package/src/adapters/review-identity-stamper.js +0 -34
- package/src/adapters/review-identity-stamper.js.map +0 -1
- package/src/bin/codex-trust.d.ts +0 -105
- package/src/bin/codex-trust.js +0 -205
- package/src/bin/codex-trust.js.map +0 -1
- package/src/bin/dev-hook-install.d.ts +0 -1
- package/src/bin/dev-hook-install.js +0 -82
- package/src/bin/dev-hook-install.js.map +0 -1
- package/src/bin/dev-hook-uninstall.d.ts +0 -1
- package/src/bin/dev-hook-uninstall.js +0 -45
- package/src/bin/dev-hook-uninstall.js.map +0 -1
- package/src/bin/hook-registration.d.ts +0 -429
- package/src/bin/hook-registration.js +0 -661
- package/src/bin/hook-registration.js.map +0 -1
- package/src/bin/install-entry.d.ts +0 -19
- package/src/bin/install-entry.js +0 -128
- package/src/bin/install-entry.js.map +0 -1
- package/src/bin/l0-allowlist.d.ts +0 -49
- package/src/bin/l0-allowlist.js +0 -528
- package/src/bin/l0-allowlist.js.map +0 -1
- package/src/bin/l0-codex-read.d.ts +0 -21
- package/src/bin/l0-codex-read.js +0 -109
- package/src/bin/l0-codex-read.js.map +0 -1
- package/src/bin/l0-decide.d.ts +0 -50
- package/src/bin/l0-decide.js +0 -103
- package/src/bin/l0-decide.js.map +0 -1
- package/src/bin/l0-entry.d.ts +0 -103
- package/src/bin/l0-entry.js +0 -98
- package/src/bin/l0-entry.js.map +0 -1
- package/src/bin/l0-ignored-tools.d.ts +0 -38
- package/src/bin/l0-ignored-tools.js +0 -44
- package/src/bin/l0-ignored-tools.js.map +0 -1
- package/src/bin/managed-env.d.ts +0 -46
- package/src/bin/managed-env.js +0 -50
- package/src/bin/managed-env.js.map +0 -1
- package/src/bin/neighbour-hooks.d.ts +0 -42
- package/src/bin/neighbour-hooks.js +0 -177
- package/src/bin/neighbour-hooks.js.map +0 -1
- package/src/bin/reviewer-agent.d.ts +0 -19
- package/src/bin/reviewer-agent.js +0 -135
- package/src/bin/reviewer-agent.js.map +0 -1
- package/src/bin/settings-shape.d.ts +0 -37
- package/src/bin/settings-shape.js +0 -17
- package/src/bin/settings-shape.js.map +0 -1
- package/src/bin/setup-config.d.ts +0 -19
- package/src/bin/setup-config.js +0 -370
- package/src/bin/setup-config.js.map +0 -1
- package/src/bin/setup.d.ts +0 -78
- package/src/bin/setup.js +0 -400
- package/src/bin/setup.js.map +0 -1
- package/src/bin/shim-audit-log.d.ts +0 -119
- package/src/bin/shim-audit-log.js +0 -286
- package/src/bin/shim-audit-log.js.map +0 -1
- package/src/bin/shim-deny-reason.d.ts +0 -1
- package/src/bin/shim-deny-reason.js +0 -244
- package/src/bin/shim-deny-reason.js.map +0 -1
- package/src/bin/shim-drift-fix.d.ts +0 -1
- package/src/bin/shim-drift-fix.js +0 -72
- package/src/bin/shim-drift-fix.js.map +0 -1
- package/src/bin/shim-testkit.d.ts +0 -107
- package/src/bin/shim-testkit.js +0 -197
- package/src/bin/shim-testkit.js.map +0 -1
- package/src/bin/shim-version-drift.d.ts +0 -1
- package/src/bin/shim-version-drift.js +0 -164
- package/src/bin/shim-version-drift.js.map +0 -1
- package/src/bin/shim.d.ts +0 -16
- package/src/bin/shim.js +0 -636
- package/src/bin/shim.js.map +0 -1
- package/src/bin/upgrade-shim.d.ts +0 -18
- package/src/bin/upgrade-shim.js +0 -283
- package/src/bin/upgrade-shim.js.map +0 -1
- package/src/core/ai-type-context.d.ts +0 -36
- package/src/core/ai-type-context.js +0 -45
- package/src/core/ai-type-context.js.map +0 -1
- package/src/core/apply-patch-parse.d.ts +0 -36
- package/src/core/apply-patch-parse.js +0 -154
- package/src/core/apply-patch-parse.js.map +0 -1
- package/src/core/build-context.d.ts +0 -10
- package/src/core/build-context.js +0 -66
- package/src/core/build-context.js.map +0 -1
- package/src/core/command-scan.d.ts +0 -122
- package/src/core/command-scan.js +0 -282
- package/src/core/command-scan.js.map +0 -1
- package/src/core/custom-rule-adapter.d.ts +0 -22
- package/src/core/custom-rule-adapter.js +0 -50
- package/src/core/custom-rule-adapter.js.map +0 -1
- package/src/core/decision-log.d.ts +0 -190
- package/src/core/decision-log.js +0 -406
- package/src/core/decision-log.js.map +0 -1
- package/src/core/delete-scoped-rules.d.ts +0 -8
- package/src/core/delete-scoped-rules.js +0 -31
- package/src/core/delete-scoped-rules.js.map +0 -1
- package/src/core/disable-directives.d.ts +0 -8
- package/src/core/disable-directives.js +0 -80
- package/src/core/disable-directives.js.map +0 -1
- package/src/core/effective-tree.d.ts +0 -204
- package/src/core/effective-tree.js +0 -277
- package/src/core/effective-tree.js.map +0 -1
- package/src/core/excluded-path-escape.d.ts +0 -101
- package/src/core/excluded-path-escape.js +0 -236
- package/src/core/excluded-path-escape.js.map +0 -1
- package/src/core/excluded-paths.d.ts +0 -23
- package/src/core/excluded-paths.js +0 -54
- package/src/core/excluded-paths.js.map +0 -1
- package/src/core/fix-hint.d.ts +0 -40
- package/src/core/fix-hint.js +0 -53
- package/src/core/fix-hint.js.map +0 -1
- package/src/core/force-to-root.d.ts +0 -32
- package/src/core/force-to-root.js +0 -60
- package/src/core/force-to-root.js.map +0 -1
- package/src/core/guard-index-doc.d.ts +0 -63
- package/src/core/guard-index-doc.js +0 -172
- package/src/core/guard-index-doc.js.map +0 -1
- package/src/core/instruct-ai-writer.d.ts +0 -1
- package/src/core/instruct-ai-writer.js +0 -6
- package/src/core/instruct-ai-writer.js.map +0 -1
- package/src/core/l0-fault-codes.d.ts +0 -85
- package/src/core/l0-fault-codes.js +0 -121
- package/src/core/l0-fault-codes.js.map +0 -1
- package/src/core/l0-matrix.d.ts +0 -114
- package/src/core/l0-matrix.js +0 -416
- package/src/core/l0-matrix.js.map +0 -1
- package/src/core/l0-tooling-doc.d.ts +0 -45
- package/src/core/l0-tooling-doc.js +0 -258
- package/src/core/l0-tooling-doc.js.map +0 -1
- package/src/core/l1-doc.d.ts +0 -7
- package/src/core/l1-doc.js +0 -340
- package/src/core/l1-doc.js.map +0 -1
- package/src/core/l1-matrix-doc.d.ts +0 -31
- package/src/core/l1-matrix-doc.js +0 -111
- package/src/core/l1-matrix-doc.js.map +0 -1
- package/src/core/l1-rows.d.ts +0 -167
- package/src/core/l1-rows.js +0 -262
- package/src/core/l1-rows.js.map +0 -1
- package/src/core/l2-doc.d.ts +0 -7
- package/src/core/l2-doc.js +0 -385
- package/src/core/l2-doc.js.map +0 -1
- package/src/core/l2-matrix-doc.d.ts +0 -23
- package/src/core/l2-matrix-doc.js +0 -72
- package/src/core/l2-matrix-doc.js.map +0 -1
- package/src/core/l2-row.d.ts +0 -54
- package/src/core/l2-row.js +0 -75
- package/src/core/l2-row.js.map +0 -1
- package/src/core/l2-rows.d.ts +0 -56
- package/src/core/l2-rows.js +0 -272
- package/src/core/l2-rows.js.map +0 -1
- package/src/core/load-config.d.ts +0 -1
- package/src/core/load-config.js +0 -9
- package/src/core/load-config.js.map +0 -1
- package/src/core/log-stream.d.ts +0 -117
- package/src/core/log-stream.js +0 -156
- package/src/core/log-stream.js.map +0 -1
- package/src/core/log-streams.d.ts +0 -48
- package/src/core/log-streams.js +0 -55
- package/src/core/log-streams.js.map +0 -1
- package/src/core/log-target.d.ts +0 -21
- package/src/core/log-target.js +0 -29
- package/src/core/log-target.js.map +0 -1
- package/src/core/main-sync-log.d.ts +0 -16
- package/src/core/main-sync-log.js +0 -105
- package/src/core/main-sync-log.js.map +0 -1
- package/src/core/main-sync-refresh.d.ts +0 -39
- package/src/core/main-sync-refresh.js +0 -96
- package/src/core/main-sync-refresh.js.map +0 -1
- package/src/core/main-sync-timeout.d.ts +0 -32
- package/src/core/main-sync-timeout.js +0 -94
- package/src/core/main-sync-timeout.js.map +0 -1
- package/src/core/matrix-cures.d.ts +0 -12
- package/src/core/matrix-cures.js +0 -56
- package/src/core/matrix-cures.js.map +0 -1
- package/src/core/missing-directory.d.ts +0 -38
- package/src/core/missing-directory.js +0 -66
- package/src/core/missing-directory.js.map +0 -1
- package/src/core/read-only-inspection.d.ts +0 -34
- package/src/core/read-only-inspection.js +0 -88
- package/src/core/read-only-inspection.js.map +0 -1
- package/src/core/rejection-log.d.ts +0 -9
- package/src/core/rejection-log.js +0 -258
- package/src/core/rejection-log.js.map +0 -1
- package/src/core/report.d.ts +0 -21
- package/src/core/report.js +0 -73
- package/src/core/report.js.map +0 -1
- package/src/core/rule-base.d.ts +0 -39
- package/src/core/rule-base.js +0 -36
- package/src/core/rule-base.js.map +0 -1
- package/src/core/rules/branch-creation-guard.d.ts +0 -113
- package/src/core/rules/branch-creation-guard.js +0 -422
- package/src/core/rules/branch-creation-guard.js.map +0 -1
- package/src/core/rules/branch-switch-scan.d.ts +0 -43
- package/src/core/rules/branch-switch-scan.js +0 -132
- package/src/core/rules/branch-switch-scan.js.map +0 -1
- package/src/core/rules/build-output-pipe-guard.d.ts +0 -56
- package/src/core/rules/build-output-pipe-guard.js +0 -120
- package/src/core/rules/build-output-pipe-guard.js.map +0 -1
- package/src/core/rules/build-output-pipe-scan.d.ts +0 -47
- package/src/core/rules/build-output-pipe-scan.js +0 -84
- package/src/core/rules/build-output-pipe-scan.js.map +0 -1
- package/src/core/rules/cap-remedies.d.ts +0 -39
- package/src/core/rules/cap-remedies.js +0 -59
- package/src/core/rules/cap-remedies.js.map +0 -1
- package/src/core/rules/commit-message-substitution-guard.d.ts +0 -72
- package/src/core/rules/commit-message-substitution-guard.js +0 -134
- package/src/core/rules/commit-message-substitution-guard.js.map +0 -1
- package/src/core/rules/commit-message-substitution-scan.d.ts +0 -42
- package/src/core/rules/commit-message-substitution-scan.js +0 -145
- package/src/core/rules/commit-message-substitution-scan.js.map +0 -1
- package/src/core/rules/content-read-scan.d.ts +0 -76
- package/src/core/rules/content-read-scan.js +0 -176
- package/src/core/rules/content-read-scan.js.map +0 -1
- package/src/core/rules/cure-prefix-scan.d.ts +0 -64
- package/src/core/rules/cure-prefix-scan.js +0 -133
- package/src/core/rules/cure-prefix-scan.js.map +0 -1
- package/src/core/rules/feature-branch-guard.d.ts +0 -121
- package/src/core/rules/feature-branch-guard.js +0 -326
- package/src/core/rules/feature-branch-guard.js.map +0 -1
- package/src/core/rules/judged-tree.d.ts +0 -66
- package/src/core/rules/judged-tree.js +0 -97
- package/src/core/rules/judged-tree.js.map +0 -1
- package/src/core/rules/main-freshness.d.ts +0 -37
- package/src/core/rules/main-freshness.js +0 -61
- package/src/core/rules/main-freshness.js.map +0 -1
- package/src/core/rules/merge-in-progress-guard.d.ts +0 -17
- package/src/core/rules/merge-in-progress-guard.js +0 -122
- package/src/core/rules/merge-in-progress-guard.js.map +0 -1
- package/src/core/rules/merged-branch-bash-guard.d.ts +0 -62
- package/src/core/rules/merged-branch-bash-guard.js +0 -170
- package/src/core/rules/merged-branch-bash-guard.js.map +0 -1
- package/src/core/rules/merged-branch-message.d.ts +0 -59
- package/src/core/rules/merged-branch-message.js +0 -137
- package/src/core/rules/merged-branch-message.js.map +0 -1
- package/src/core/rules/pr-creation-or-push-guard.d.ts +0 -26
- package/src/core/rules/pr-creation-or-push-guard.js +0 -146
- package/src/core/rules/pr-creation-or-push-guard.js.map +0 -1
- package/src/core/rules/pr-merge-guard.d.ts +0 -36
- package/src/core/rules/pr-merge-guard.js +0 -86
- package/src/core/rules/pr-merge-guard.js.map +0 -1
- package/src/core/rules/read-stale-guard.d.ts +0 -136
- package/src/core/rules/read-stale-guard.js +0 -326
- package/src/core/rules/read-stale-guard.js.map +0 -1
- package/src/core/rules/recovery-allowlist.d.ts +0 -49
- package/src/core/rules/recovery-allowlist.js +0 -187
- package/src/core/rules/recovery-allowlist.js.map +0 -1
- package/src/core/rules/redirect-how-to-merge-main.d.ts +0 -16
- package/src/core/rules/redirect-how-to-merge-main.js +0 -157
- package/src/core/rules/redirect-how-to-merge-main.js.map +0 -1
- package/src/core/rules/shell-segment-scan.d.ts +0 -64
- package/src/core/rules/shell-segment-scan.js +0 -88
- package/src/core/rules/shell-segment-scan.js.map +0 -1
- package/src/core/rules/stale-main-bash-guard.d.ts +0 -198
- package/src/core/rules/stale-main-bash-guard.js +0 -361
- package/src/core/rules/stale-main-bash-guard.js.map +0 -1
- package/src/core/rules/stale-main-message.d.ts +0 -62
- package/src/core/rules/stale-main-message.js +0 -102
- package/src/core/rules/stale-main-message.js.map +0 -1
- package/src/core/rules/tree-recovery.d.ts +0 -92
- package/src/core/rules/tree-recovery.js +0 -165
- package/src/core/rules/tree-recovery.js.map +0 -1
- package/src/core/rules/wait-spin-guard.d.ts +0 -128
- package/src/core/rules/wait-spin-guard.js +0 -211
- package/src/core/rules/wait-spin-guard.js.map +0 -1
- package/src/core/rules/wait-spin-scan.d.ts +0 -118
- package/src/core/rules/wait-spin-scan.js +0 -203
- package/src/core/rules/wait-spin-scan.js.map +0 -1
- package/src/core/rules/whole-repo-build-guard.d.ts +0 -125
- package/src/core/rules/whole-repo-build-guard.js +0 -257
- package/src/core/rules/whole-repo-build-guard.js.map +0 -1
- package/src/core/rules/whole-repo-build-scan.d.ts +0 -28
- package/src/core/rules/whole-repo-build-scan.js +0 -198
- package/src/core/rules/whole-repo-build-scan.js.map +0 -1
- package/src/core/session-call-history.d.ts +0 -44
- package/src/core/session-call-history.js +0 -79
- package/src/core/session-call-history.js.map +0 -1
- package/src/core/shell-read-parity.d.ts +0 -56
- package/src/core/shell-read-parity.js +0 -155
- package/src/core/shell-read-parity.js.map +0 -1
- package/src/core/strip-ts-noise.d.ts +0 -1
- package/src/core/strip-ts-noise.js +0 -185
- package/src/core/strip-ts-noise.js.map +0 -1
- package/src/core/sync-main.d.ts +0 -46
- package/src/core/sync-main.js +0 -175
- package/src/core/sync-main.js.map +0 -1
- package/src/core/target-tree.d.ts +0 -84
- package/src/core/target-tree.js +0 -148
- package/src/core/target-tree.js.map +0 -1
- package/src/core/to-error.d.ts +0 -5
- package/src/core/to-error.js +0 -37
- package/src/core/to-error.js.map +0 -1
- package/src/core/types.d.ts +0 -152
- package/src/core/types.js +0 -200
- package/src/core/types.js.map +0 -1
- package/src/core/version-sync.d.ts +0 -219
- package/src/core/version-sync.js +0 -558
- package/src/core/version-sync.js.map +0 -1
- package/src/core/webpieces-versions.d.ts +0 -98
- package/src/core/webpieces-versions.js +0 -206
- package/src/core/webpieces-versions.js.map +0 -1
- package/templates/ai-hook.sh +0 -497
- package/templates/claude-settings-hook.json +0 -28
- package/templates/webpieces-reviewer.md +0 -60
|
@@ -1,244 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.shimStaleDenyReason = shimStaleDenyReason;
|
|
4
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
5
|
-
const l0_fault_codes_1 = require("../core/l0-fault-codes");
|
|
6
|
-
const l0_allowlist_1 = require("./l0-allowlist");
|
|
7
|
-
const l0_codex_read_1 = require("./l0-codex-read");
|
|
8
|
-
const managed_env_1 = require("./managed-env");
|
|
9
|
-
const neighbour_hooks_1 = require("./neighbour-hooks");
|
|
10
|
-
const reviewer_agent_1 = require("./reviewer-agent");
|
|
11
|
-
const shim_1 = require("./shim");
|
|
12
|
-
/**
|
|
13
|
-
* THE FAIL-CLOSED DENY TEXT for a drifted managed hook surface (L0 fault S) — its own module because
|
|
14
|
-
* shim.ts is at its line cap and this is one cohesive unit: the words a blocked agent reads, and
|
|
15
|
-
* nothing else. It imports FROM shim.ts and is never imported BY it, so the graph stays acyclic.
|
|
16
|
-
*
|
|
17
|
-
* IT IS RENDERED IN THE HOUSE FORMAT, the same skeleton core/report.ts (formatReport) gives every L1
|
|
18
|
-
* and L2 deny: a header naming what was blocked, a `[guard-name]` block listing the offenders with a
|
|
19
|
-
* one-line `→ why`, what is still allowed, then numbered `Fix Option N:` lines each with its command
|
|
20
|
-
* on its own line. L0 used to be the ONLY layer in webpieces that answered in one unbroken paragraph —
|
|
21
|
-
* ~3,300 characters of it here — so the two commands that matter were buried in prose and there was no
|
|
22
|
-
* guard name to grep for. Nothing about the DECISION changed; only the shape of the words.
|
|
23
|
-
*
|
|
24
|
-
* SHORTER IS NOT THE GOAL, SCANNABLE IS. The budget below still exists (a paragraph regrows when every
|
|
25
|
-
* new finding argues its case here), but a section that earns a line gets a line.
|
|
26
|
-
*
|
|
27
|
-
* CONSTRAINT: the returned string must contain no `"` and no `\` — it is JSON-serialized by denyJson()
|
|
28
|
-
* (a stray quote/backslash would corrupt the PreToolUse decision payload, not just the text). That is an
|
|
29
|
-
* INVARIANT, not a hope, so every interpolated path is STRIPPED of both rather than trusted — a
|
|
30
|
-
* Windows-style path or an odd directory name must not be able to corrupt the decision. Locked by unit
|
|
31
|
-
* tests. An unusual root is also dropped from the `cd` cure rather than quoted (CD_PREFIX would reject it).
|
|
32
|
-
*
|
|
33
|
-
* NEWLINES ARE SAFE HERE AND NEEDED NO NEW MECHANISM. denyJson() runs JSON.stringify, which escapes a
|
|
34
|
-
* real newline to the two-character `\n` on the wire, and Claude Code's parser turns it back. This is
|
|
35
|
-
* already proven in production — every L1 deny is formatReport()'s multi-line string down this exact
|
|
36
|
-
* path. The sh half of L0 (faults D/X/U/K in renderShim) cannot do this: it printf's REASON into a JSON
|
|
37
|
-
* string literal, so it spells its newlines `${NL}` the same way it spells the ANSI escape `${ESC}`.
|
|
38
|
-
* A real newline is neither a quote nor a backslash, so the JSON-safety assertions above are untouched.
|
|
39
|
-
*/
|
|
40
|
-
class ShimStaleDeny {
|
|
41
|
-
installedVersion;
|
|
42
|
-
/** The governing root, STRIPPED of `"` and `\` for display. '' when there is none to name. */
|
|
43
|
-
safeRoot;
|
|
44
|
-
/** CLAUDE_PROJECT_DIR as this process sees it, stripped the same way. */
|
|
45
|
-
projectDir;
|
|
46
|
-
drifted;
|
|
47
|
-
inSubagent;
|
|
48
|
-
/**
|
|
49
|
-
* Whether the RAW root can carry a leading `cd <root> &&`. Tested against the raw root, never the
|
|
50
|
-
* stripped one: stripping is a display-safety measure, and cd-anchoring to a path we just mangled
|
|
51
|
-
* would prescribe a cd into a directory that does not exist. A root CD_PREFIX cannot express is
|
|
52
|
-
* simply not offered as a `cd` (raw ok ⇒ safeRoot === root).
|
|
53
|
-
*/
|
|
54
|
-
cdOk;
|
|
55
|
-
constructor(installedVersion, root, drifted, inSubagent) {
|
|
56
|
-
this.installedVersion = installedVersion;
|
|
57
|
-
this.safeRoot = root.replace(/["\\]/g, '');
|
|
58
|
-
this.projectDir = rules_config_1.claudeEnv.projectDirForLog().replace(/["\\]/g, '');
|
|
59
|
-
this.drifted = drifted;
|
|
60
|
-
this.inSubagent = inSubagent;
|
|
61
|
-
this.cdOk = root !== '' && /^[A-Za-z0-9._/@~+-]+$/.test(root);
|
|
62
|
-
}
|
|
63
|
-
render() {
|
|
64
|
-
return [
|
|
65
|
-
...this.header(),
|
|
66
|
-
...this.measured(),
|
|
67
|
-
...this.caller(),
|
|
68
|
-
...this.stillAllowed(),
|
|
69
|
-
...this.fixOptions(),
|
|
70
|
-
...this.footer(),
|
|
71
|
-
].join('\n');
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* `[managed-hook-surface]` and the surfaces that drifted, one per line.
|
|
75
|
-
*
|
|
76
|
-
* `drifted` names WHICH of the managed things moved — .claude/webpieces/ai-hook.sh, each harness's
|
|
77
|
-
* .claude/settings.json hook registration, and its managed env entry (see hook-registration.ts). It
|
|
78
|
-
* is REQUIRED, not optional: this used to be a shim-only message, and an optional list would let a
|
|
79
|
-
* caller silently keep emitting the one-file text after the surface grew — the "two spellings of one
|
|
80
|
-
* thing" shape the compatibility policy rejects. It was FOUR; guarantee-root.sh (L-1) is gone,
|
|
81
|
-
* because the guard hooks are registered ABSOLUTE now and there is no second .sh to keep byte-locked.
|
|
82
|
-
*
|
|
83
|
-
* THE CAUSE IS A LIST. It used to assert flatly "(it was reverted or hand-edited)", which is
|
|
84
|
-
* frequently FALSE — the common case is a shim whose logic simply predates this binary — and that
|
|
85
|
-
* false certainty sent a real agent hunting for a tamper that never happened.
|
|
86
|
-
*/
|
|
87
|
-
header() {
|
|
88
|
-
const verNote = this.installedVersion ? ` (installed version ${this.installedVersion})` : '';
|
|
89
|
-
const n = this.drifted.length;
|
|
90
|
-
const label = n === 1 ? '1 surface drifted' : `${String(n)} surfaces drifted`;
|
|
91
|
-
return [
|
|
92
|
-
'❌ webpieces ai-hooks blocked this call: a webpieces-managed hook surface no longer matches the installed guard binary.',
|
|
93
|
-
'',
|
|
94
|
-
(0, l0_fault_codes_1.l0GuardHeader)(l0_fault_codes_1.L0_FAULT_SHIM_STALE, label),
|
|
95
|
-
...this.drifted.map((surface) => ` ${surface}`),
|
|
96
|
-
` → webpieces manages those files as ONE set, GENERATED by the INSTALLED @webpieces/ai-hook-rules${verNote}; what is on disk is missing, reverted, hand-edited, or predating this binary. The env entry is ${managed_env_1.BASH_CWD_ENV_KEY}=${managed_env_1.BASH_CWD_ENV_VALUE}, which pins the Bash cwd to the project root, identically for every subagent because settings env is inherited.`,
|
|
97
|
-
...this.neighbourNote(),
|
|
98
|
-
...this.reviewerAgentNote(),
|
|
99
|
-
` → ${(0, l0_fault_codes_1.l0MatrixCitation)(l0_fault_codes_1.L0_FAULT_SHIM_STALE)}`,
|
|
100
|
-
'',
|
|
101
|
-
];
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* The fourth surface's line, spent ONLY when that surface is the one that moved.
|
|
105
|
-
*
|
|
106
|
-
* Conditional rather than always-on because of what it is: the other three are webpieces' own files
|
|
107
|
-
* and a reader meeting fault S needs no introduction to them, whereas this one is about the READER'S
|
|
108
|
-
* hooks, registered beside ours, and the way it fails is the one thing they cannot infer — a relative
|
|
109
|
-
* entry path that fails to load exits non-zero, which the hooks reference defines as NON-BLOCKING, so
|
|
110
|
-
* the guard silently stops guarding rather than blocking. Printing that when nothing relative is
|
|
111
|
-
* registered would be argument inside a message with a hard budget; printing it when the surface IS
|
|
112
|
-
* drifted is the only place the reader learns why a guard they wrote was not running.
|
|
113
|
-
*/
|
|
114
|
-
neighbourNote() {
|
|
115
|
-
if (!this.drifted.some((s) => s.endsWith(neighbour_hooks_1.NEIGHBOUR_SURFACE_SUFFIX)))
|
|
116
|
-
return [];
|
|
117
|
-
return [' → the neighbour-hooks surface is YOUR hooks beside ours: a relative entry path fails to load off the repo root, and that exit is NON-BLOCKING, so the guard silently stops guarding. Fix Option 1 anchors each one and prints it.'];
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* The reviewer agent's line, spent ONLY when it is the surface that moved — it is the one managed file
|
|
121
|
-
* that is not part of the hook itself, so a reader cannot infer why a PR-review agent blocks a Bash call.
|
|
122
|
-
*/
|
|
123
|
-
reviewerAgentNote() {
|
|
124
|
-
if (!this.drifted.includes(reviewer_agent_1.REVIEWER_AGENT_MARKER))
|
|
125
|
-
return [];
|
|
126
|
-
return [` → ${reviewer_agent_1.REVIEWER_AGENT_MARKER} is the generic PR-gate reviewer agent webpieces owns; a hand-edited copy would silently change how every PR is reviewed. Fix Option 1 rewrites it. To customize reviews, set commands.pr-gate overrideReviewerAgent to true and reviewerAgentName to an agent of your own instead.`];
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* WHERE IT WAS MEASURED, in the deny itself and not only in the logs. #574 put `root=` and
|
|
130
|
-
* `projectDir=` on every L1 invocation line (see decision-log / ClaudeEnv.projectDirForLog, whose
|
|
131
|
-
* `<unset>` token keeps "variable absent" distinguishable from "set to empty"). The log is forensics
|
|
132
|
-
* AFTER the fact; the deny is what a blocked agent reads IN the moment, and the absence of exactly
|
|
133
|
-
* these two fields is what sent a real agent chasing the wrong mechanism for four cures. Same field
|
|
134
|
-
* names on purpose, so the deny text and the log lines grep together.
|
|
135
|
-
*
|
|
136
|
-
* Agreement is the routine case; DISAGREEMENT is the signature of the session-root-vs-cwd split this
|
|
137
|
-
* guard was rewritten to make unconstructible, so it gets said out loud rather than left to inference.
|
|
138
|
-
*/
|
|
139
|
-
measured() {
|
|
140
|
-
if (this.safeRoot === '')
|
|
141
|
-
return [];
|
|
142
|
-
return [
|
|
143
|
-
'Where this was measured:',
|
|
144
|
-
` root=${this.safeRoot} - the tree whose shim was compared, and the one to repair`,
|
|
145
|
-
` projectDir=${this.projectDir} - CLAUDE_PROJECT_DIR as this process sees it; <unset> = absent, not set-but-empty`,
|
|
146
|
-
` → ${this.verdict()}`,
|
|
147
|
-
'',
|
|
148
|
-
];
|
|
149
|
-
}
|
|
150
|
-
verdict() {
|
|
151
|
-
return this.callerIsInTheTree()
|
|
152
|
-
? 'These two AGREE, so this is the ordinary case - the tree you are in is the tree being judged.'
|
|
153
|
-
: 'These two DISAGREE - the tree being judged is NOT the one CLAUDE_PROJECT_DIR names, so cure the root= tree and do not assume your cwd is it.';
|
|
154
|
-
}
|
|
155
|
-
/** True when the tree needing repair is the caller's own tree — the input the caller branch gates on. */
|
|
156
|
-
callerIsInTheTree() {
|
|
157
|
-
return this.safeRoot === this.projectDir;
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* THE CALLER-GATED BRANCH. It changes the WORDS ONLY — never the block/allow decision, never which
|
|
161
|
-
* command is printed, and never which tree anything acts on (that is decided from the path, which is
|
|
162
|
-
* why the deleted AgentIdentity class is NOT coming back for anything but message shape; agent
|
|
163
|
-
* identity was measured untrustworthy as a location signal when a worktree agent resumed on the
|
|
164
|
-
* primary clone after its tree was reaped).
|
|
165
|
-
*
|
|
166
|
-
* Two inputs, both already on hand:
|
|
167
|
-
* 1. `inSubagent` — from the payload's `agent_id`, which Claude Code populates ONLY off the main
|
|
168
|
-
* loop (main falls back to the session id, so the field is absent there). `agent_type` is NOT
|
|
169
|
-
* usable: it is always populated and discriminates nothing. REQUIRED for the same reason
|
|
170
|
-
* `drifted` is — an optional flag would let a caller keep emitting the main-loop text.
|
|
171
|
-
* 2. root= vs projectDir= — different means the caller is not standing in the tree to repair.
|
|
172
|
-
*
|
|
173
|
-
* A main agent, and a subagent whose cwd IS the tree, get the cure and nothing else: they can run it,
|
|
174
|
-
* see the result and commit it. A WORKTREE-ISOLATED subagent gets one extra step, and only because it
|
|
175
|
-
* is true — MEASURED 2026-08-11: such an agent CAN run `cd <main> && pnpm exec wp-upgrade-shim` and it
|
|
176
|
-
* works (the harness refuses cross-tree GIT operations, not this), but it can neither verify nor
|
|
177
|
-
* commit the result, because `git -C <main>` is refused. So the escalation is of the COMMIT, not of
|
|
178
|
-
* the repair, and the text must never tell it a local cure cannot work — the older wording asserted
|
|
179
|
-
* exactly that and was false in the window where it fired (measured 2026-08-10: a worktree subagent
|
|
180
|
-
* cured in place and the block lifted, with the deny's own root= naming that worktree).
|
|
181
|
-
*
|
|
182
|
-
* WHAT IS DELIBERATELY GONE: the "ask the coordinator to run pnpm install so both trees are on the
|
|
183
|
-
* same @webpieces version" clause. Both hooks are registered ABSOLUTE, so every tree is already
|
|
184
|
-
* judged by MAIN's shim and MAIN's binary — there is no version alignment left to ask for, and
|
|
185
|
-
* asking sends an agent after a non-problem.
|
|
186
|
-
*/
|
|
187
|
-
caller() {
|
|
188
|
-
// No governing root to name means no `Where this was measured` section either, so there is no
|
|
189
|
-
// root= for this text to point at and nothing to escalate ABOUT. Silence beats a dangling field.
|
|
190
|
-
if (this.safeRoot === '' || !this.inSubagent || this.callerIsInTheTree())
|
|
191
|
-
return [];
|
|
192
|
-
return [
|
|
193
|
-
'You are a SUBAGENT and root= is not the tree you are standing in, so this takes TWO steps:',
|
|
194
|
-
' 1. Run Fix Option 1 below exactly as printed. It is already anchored to the tree that must change, and a worktree-isolated subagent CAN run it against another tree - that was measured and it works, so never conclude a local cure cannot work.',
|
|
195
|
-
` 2. Then ESCALATE THE COMMIT, which is the part you cannot do: git -C ${this.safeRoot} is refused here, so you can neither verify nor commit what the cure regenerated. Tell the coordinator to run git status in ${this.safeRoot} and commit the regenerated shim.`,
|
|
196
|
-
'',
|
|
197
|
-
];
|
|
198
|
-
}
|
|
199
|
-
stillAllowed() {
|
|
200
|
-
return [
|
|
201
|
-
'Still allowed while this block is up:',
|
|
202
|
-
` - any Read, and ${l0_codex_read_1.CODEX_READ_STILL_ALLOWED}`,
|
|
203
|
-
' - any Write/Edit whose target is webpieces.config.json',
|
|
204
|
-
' - every command on the L0 allowlist, including both Fix Options below',
|
|
205
|
-
' THIS IS NOT A DEADLOCK: both options are explicitly ALLOWED through, so run one YOURSELF now - do not hand it back to the human. Every OTHER tool call is blocked until every managed surface matches again.',
|
|
206
|
-
'',
|
|
207
|
-
];
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* The two cures, house-numbered. ORDER IS LOAD-BEARING: wp-upgrade-shim LEADS because it is the only
|
|
211
|
-
* cure that repairs every managed surface, it touches no config and imports only fs/path, so it
|
|
212
|
-
* runs on a tree too broken to load the rule engine. The `cp` stays last as the pre-0.4.408 fallback.
|
|
213
|
-
*
|
|
214
|
-
* Both are anchored with a leading `cd <root> &&` when the root allows it — CD_PREFIX_*_ANCHORED
|
|
215
|
-
* tolerates exactly that one prefix (locked by unit test), and it is what keeps the cure curable when
|
|
216
|
-
* the AI's cwd is a DIFFERENT tree than the one being judged. OPTION 2 is a relative-path `cp`, so it
|
|
217
|
-
* is even MORE cwd-sensitive than OPTION 1 — it is anchored too. Never a SECOND `cd … &&`: the
|
|
218
|
-
* allowlist matches the whole command and three segments are denied.
|
|
219
|
-
*/
|
|
220
|
-
fixOptions() {
|
|
221
|
-
const anchor = (cmd) => (this.cdOk ? `cd ${this.safeRoot} && ${cmd}` : cmd);
|
|
222
|
-
return [
|
|
223
|
-
' Fix Option 1: (preferred) the only cure that repairs every managed surface, and it runs on a broken tree',
|
|
224
|
-
` run EXACTLY: '${anchor(l0_allowlist_1.UPGRADE_SHIM_CMD)}'`,
|
|
225
|
-
` Fix Option 2: PARTIAL - repairs ${shim_1.SHIM_MARKER} only. Pick it ONLY when the installed @webpieces/ai-hook-rules is older than 0.4.408, where Fix Option 1 does not exist yet; then upgrade and run Fix Option 1.`,
|
|
226
|
-
` run EXACTLY: '${anchor(l0_allowlist_1.RESTORE_SHIM_CMD)}'`,
|
|
227
|
-
` NOT an option: do NOT use the bare '${l0_allowlist_1.INSTALL_HOOKS_CMD}' here - it also migrates your config and PROMPTS for a hook target twice, which hangs a non-interactive session.`,
|
|
228
|
-
'',
|
|
229
|
-
];
|
|
230
|
-
}
|
|
231
|
-
footer() {
|
|
232
|
-
return [
|
|
233
|
-
shim_1.NO_CHAINING_RULE,
|
|
234
|
-
`If you meant to remove @webpieces/ai-hook-rules, delete its hooks from .claude/settings.json rather than reverting ${shim_1.SHIM_MARKER}.`,
|
|
235
|
-
];
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
// The ONE entry point its two call sites (hook-core's fault-S deny, and the L0 fault table in
|
|
239
|
-
// l0-matrix) import. The rendering lives on ShimStaleDeny above, per CLAUDE.md; this is the seam.
|
|
240
|
-
// webpieces-disable no-function-outside-class -- one-line constructor+render seam for ShimStaleDeny, in the dependency-free shim module (it must stay callable from a tree too broken to build a DI container).
|
|
241
|
-
function shimStaleDenyReason(installedVersion, root, drifted, inSubagent) {
|
|
242
|
-
return new ShimStaleDeny(installedVersion, root, drifted, inSubagent).render();
|
|
243
|
-
}
|
|
244
|
-
//# sourceMappingURL=shim-deny-reason.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shim-deny-reason.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/shim-deny-reason.ts"],"names":[],"mappings":"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","sourcesContent":["import { claudeEnv } from '@webpieces/rules-config';\n\nimport { L0_FAULT_SHIM_STALE, l0GuardHeader, l0MatrixCitation } from '../core/l0-fault-codes';\nimport { INSTALL_HOOKS_CMD, RESTORE_SHIM_CMD, UPGRADE_SHIM_CMD } from './l0-allowlist';\nimport { CODEX_READ_STILL_ALLOWED } from './l0-codex-read';\nimport { BASH_CWD_ENV_KEY, BASH_CWD_ENV_VALUE } from './managed-env';\nimport { NEIGHBOUR_SURFACE_SUFFIX } from './neighbour-hooks';\nimport { REVIEWER_AGENT_MARKER } from './reviewer-agent';\nimport { NO_CHAINING_RULE, SHIM_MARKER } from './shim';\n\n/**\n * THE FAIL-CLOSED DENY TEXT for a drifted managed hook surface (L0 fault S) — its own module because\n * shim.ts is at its line cap and this is one cohesive unit: the words a blocked agent reads, and\n * nothing else. It imports FROM shim.ts and is never imported BY it, so the graph stays acyclic.\n *\n * IT IS RENDERED IN THE HOUSE FORMAT, the same skeleton core/report.ts (formatReport) gives every L1\n * and L2 deny: a header naming what was blocked, a `[guard-name]` block listing the offenders with a\n * one-line `→ why`, what is still allowed, then numbered `Fix Option N:` lines each with its command\n * on its own line. L0 used to be the ONLY layer in webpieces that answered in one unbroken paragraph —\n * ~3,300 characters of it here — so the two commands that matter were buried in prose and there was no\n * guard name to grep for. Nothing about the DECISION changed; only the shape of the words.\n *\n * SHORTER IS NOT THE GOAL, SCANNABLE IS. The budget below still exists (a paragraph regrows when every\n * new finding argues its case here), but a section that earns a line gets a line.\n *\n * CONSTRAINT: the returned string must contain no `\"` and no `\\` — it is JSON-serialized by denyJson()\n * (a stray quote/backslash would corrupt the PreToolUse decision payload, not just the text). That is an\n * INVARIANT, not a hope, so every interpolated path is STRIPPED of both rather than trusted — a\n * Windows-style path or an odd directory name must not be able to corrupt the decision. Locked by unit\n * tests. An unusual root is also dropped from the `cd` cure rather than quoted (CD_PREFIX would reject it).\n *\n * NEWLINES ARE SAFE HERE AND NEEDED NO NEW MECHANISM. denyJson() runs JSON.stringify, which escapes a\n * real newline to the two-character `\\n` on the wire, and Claude Code's parser turns it back. This is\n * already proven in production — every L1 deny is formatReport()'s multi-line string down this exact\n * path. The sh half of L0 (faults D/X/U/K in renderShim) cannot do this: it printf's REASON into a JSON\n * string literal, so it spells its newlines `${NL}` the same way it spells the ANSI escape `${ESC}`.\n * A real newline is neither a quote nor a backslash, so the JSON-safety assertions above are untouched.\n */\nclass ShimStaleDeny {\n private readonly installedVersion: string;\n /** The governing root, STRIPPED of `\"` and `\\` for display. '' when there is none to name. */\n private readonly safeRoot: string;\n /** CLAUDE_PROJECT_DIR as this process sees it, stripped the same way. */\n private readonly projectDir: string;\n private readonly drifted: readonly string[];\n private readonly inSubagent: boolean;\n /**\n * Whether the RAW root can carry a leading `cd <root> &&`. Tested against the raw root, never the\n * stripped one: stripping is a display-safety measure, and cd-anchoring to a path we just mangled\n * would prescribe a cd into a directory that does not exist. A root CD_PREFIX cannot express is\n * simply not offered as a `cd` (raw ok ⇒ safeRoot === root).\n */\n private readonly cdOk: boolean;\n\n constructor(installedVersion: string, root: string, drifted: readonly string[], inSubagent: boolean) {\n this.installedVersion = installedVersion;\n this.safeRoot = root.replace(/[\"\\\\]/g, '');\n this.projectDir = claudeEnv.projectDirForLog().replace(/[\"\\\\]/g, '');\n this.drifted = drifted;\n this.inSubagent = inSubagent;\n this.cdOk = root !== '' && /^[A-Za-z0-9._/@~+-]+$/.test(root);\n }\n\n render(): string {\n return [\n ...this.header(),\n ...this.measured(),\n ...this.caller(),\n ...this.stillAllowed(),\n ...this.fixOptions(),\n ...this.footer(),\n ].join('\\n');\n }\n\n /**\n * `[managed-hook-surface]` and the surfaces that drifted, one per line.\n *\n * `drifted` names WHICH of the managed things moved — .claude/webpieces/ai-hook.sh, each harness's\n * .claude/settings.json hook registration, and its managed env entry (see hook-registration.ts). It\n * is REQUIRED, not optional: this used to be a shim-only message, and an optional list would let a\n * caller silently keep emitting the one-file text after the surface grew — the \"two spellings of one\n * thing\" shape the compatibility policy rejects. It was FOUR; guarantee-root.sh (L-1) is gone,\n * because the guard hooks are registered ABSOLUTE now and there is no second .sh to keep byte-locked.\n *\n * THE CAUSE IS A LIST. It used to assert flatly \"(it was reverted or hand-edited)\", which is\n * frequently FALSE — the common case is a shim whose logic simply predates this binary — and that\n * false certainty sent a real agent hunting for a tamper that never happened.\n */\n private header(): string[] {\n const verNote = this.installedVersion ? ` (installed version ${this.installedVersion})` : '';\n const n = this.drifted.length;\n const label = n === 1 ? '1 surface drifted' : `${String(n)} surfaces drifted`;\n return [\n '❌ webpieces ai-hooks blocked this call: a webpieces-managed hook surface no longer matches the installed guard binary.',\n '',\n l0GuardHeader(L0_FAULT_SHIM_STALE, label),\n ...this.drifted.map((surface: string): string => ` ${surface}`),\n ` → webpieces manages those files as ONE set, GENERATED by the INSTALLED @webpieces/ai-hook-rules${verNote}; what is on disk is missing, reverted, hand-edited, or predating this binary. The env entry is ${BASH_CWD_ENV_KEY}=${BASH_CWD_ENV_VALUE}, which pins the Bash cwd to the project root, identically for every subagent because settings env is inherited.`,\n ...this.neighbourNote(),\n ...this.reviewerAgentNote(),\n ` → ${l0MatrixCitation(L0_FAULT_SHIM_STALE)}`,\n '',\n ];\n }\n\n /**\n * The fourth surface's line, spent ONLY when that surface is the one that moved.\n *\n * Conditional rather than always-on because of what it is: the other three are webpieces' own files\n * and a reader meeting fault S needs no introduction to them, whereas this one is about the READER'S\n * hooks, registered beside ours, and the way it fails is the one thing they cannot infer — a relative\n * entry path that fails to load exits non-zero, which the hooks reference defines as NON-BLOCKING, so\n * the guard silently stops guarding rather than blocking. Printing that when nothing relative is\n * registered would be argument inside a message with a hard budget; printing it when the surface IS\n * drifted is the only place the reader learns why a guard they wrote was not running.\n */\n private neighbourNote(): string[] {\n if (!this.drifted.some((s: string): boolean => s.endsWith(NEIGHBOUR_SURFACE_SUFFIX))) return [];\n return [' → the neighbour-hooks surface is YOUR hooks beside ours: a relative entry path fails to load off the repo root, and that exit is NON-BLOCKING, so the guard silently stops guarding. Fix Option 1 anchors each one and prints it.'];\n }\n\n /**\n * The reviewer agent's line, spent ONLY when it is the surface that moved — it is the one managed file\n * that is not part of the hook itself, so a reader cannot infer why a PR-review agent blocks a Bash call.\n */\n private reviewerAgentNote(): string[] {\n if (!this.drifted.includes(REVIEWER_AGENT_MARKER)) return [];\n return [` → ${REVIEWER_AGENT_MARKER} is the generic PR-gate reviewer agent webpieces owns; a hand-edited copy would silently change how every PR is reviewed. Fix Option 1 rewrites it. To customize reviews, set commands.pr-gate overrideReviewerAgent to true and reviewerAgentName to an agent of your own instead.`];\n }\n\n /**\n * WHERE IT WAS MEASURED, in the deny itself and not only in the logs. #574 put `root=` and\n * `projectDir=` on every L1 invocation line (see decision-log / ClaudeEnv.projectDirForLog, whose\n * `<unset>` token keeps \"variable absent\" distinguishable from \"set to empty\"). The log is forensics\n * AFTER the fact; the deny is what a blocked agent reads IN the moment, and the absence of exactly\n * these two fields is what sent a real agent chasing the wrong mechanism for four cures. Same field\n * names on purpose, so the deny text and the log lines grep together.\n *\n * Agreement is the routine case; DISAGREEMENT is the signature of the session-root-vs-cwd split this\n * guard was rewritten to make unconstructible, so it gets said out loud rather than left to inference.\n */\n private measured(): string[] {\n if (this.safeRoot === '') return [];\n return [\n 'Where this was measured:',\n ` root=${this.safeRoot} - the tree whose shim was compared, and the one to repair`,\n ` projectDir=${this.projectDir} - CLAUDE_PROJECT_DIR as this process sees it; <unset> = absent, not set-but-empty`,\n ` → ${this.verdict()}`,\n '',\n ];\n }\n\n private verdict(): string {\n return this.callerIsInTheTree()\n ? 'These two AGREE, so this is the ordinary case - the tree you are in is the tree being judged.'\n : 'These two DISAGREE - the tree being judged is NOT the one CLAUDE_PROJECT_DIR names, so cure the root= tree and do not assume your cwd is it.';\n }\n\n /** True when the tree needing repair is the caller's own tree — the input the caller branch gates on. */\n private callerIsInTheTree(): boolean {\n return this.safeRoot === this.projectDir;\n }\n\n /**\n * THE CALLER-GATED BRANCH. It changes the WORDS ONLY — never the block/allow decision, never which\n * command is printed, and never which tree anything acts on (that is decided from the path, which is\n * why the deleted AgentIdentity class is NOT coming back for anything but message shape; agent\n * identity was measured untrustworthy as a location signal when a worktree agent resumed on the\n * primary clone after its tree was reaped).\n *\n * Two inputs, both already on hand:\n * 1. `inSubagent` — from the payload's `agent_id`, which Claude Code populates ONLY off the main\n * loop (main falls back to the session id, so the field is absent there). `agent_type` is NOT\n * usable: it is always populated and discriminates nothing. REQUIRED for the same reason\n * `drifted` is — an optional flag would let a caller keep emitting the main-loop text.\n * 2. root= vs projectDir= — different means the caller is not standing in the tree to repair.\n *\n * A main agent, and a subagent whose cwd IS the tree, get the cure and nothing else: they can run it,\n * see the result and commit it. A WORKTREE-ISOLATED subagent gets one extra step, and only because it\n * is true — MEASURED 2026-08-11: such an agent CAN run `cd <main> && pnpm exec wp-upgrade-shim` and it\n * works (the harness refuses cross-tree GIT operations, not this), but it can neither verify nor\n * commit the result, because `git -C <main>` is refused. So the escalation is of the COMMIT, not of\n * the repair, and the text must never tell it a local cure cannot work — the older wording asserted\n * exactly that and was false in the window where it fired (measured 2026-08-10: a worktree subagent\n * cured in place and the block lifted, with the deny's own root= naming that worktree).\n *\n * WHAT IS DELIBERATELY GONE: the \"ask the coordinator to run pnpm install so both trees are on the\n * same @webpieces version\" clause. Both hooks are registered ABSOLUTE, so every tree is already\n * judged by MAIN's shim and MAIN's binary — there is no version alignment left to ask for, and\n * asking sends an agent after a non-problem.\n */\n private caller(): string[] {\n // No governing root to name means no `Where this was measured` section either, so there is no\n // root= for this text to point at and nothing to escalate ABOUT. Silence beats a dangling field.\n if (this.safeRoot === '' || !this.inSubagent || this.callerIsInTheTree()) return [];\n return [\n 'You are a SUBAGENT and root= is not the tree you are standing in, so this takes TWO steps:',\n ' 1. Run Fix Option 1 below exactly as printed. It is already anchored to the tree that must change, and a worktree-isolated subagent CAN run it against another tree - that was measured and it works, so never conclude a local cure cannot work.',\n ` 2. Then ESCALATE THE COMMIT, which is the part you cannot do: git -C ${this.safeRoot} is refused here, so you can neither verify nor commit what the cure regenerated. Tell the coordinator to run git status in ${this.safeRoot} and commit the regenerated shim.`,\n '',\n ];\n }\n\n private stillAllowed(): string[] {\n return [\n 'Still allowed while this block is up:',\n ` - any Read, and ${CODEX_READ_STILL_ALLOWED}`,\n ' - any Write/Edit whose target is webpieces.config.json',\n ' - every command on the L0 allowlist, including both Fix Options below',\n ' THIS IS NOT A DEADLOCK: both options are explicitly ALLOWED through, so run one YOURSELF now - do not hand it back to the human. Every OTHER tool call is blocked until every managed surface matches again.',\n '',\n ];\n }\n\n /**\n * The two cures, house-numbered. ORDER IS LOAD-BEARING: wp-upgrade-shim LEADS because it is the only\n * cure that repairs every managed surface, it touches no config and imports only fs/path, so it\n * runs on a tree too broken to load the rule engine. The `cp` stays last as the pre-0.4.408 fallback.\n *\n * Both are anchored with a leading `cd <root> &&` when the root allows it — CD_PREFIX_*_ANCHORED\n * tolerates exactly that one prefix (locked by unit test), and it is what keeps the cure curable when\n * the AI's cwd is a DIFFERENT tree than the one being judged. OPTION 2 is a relative-path `cp`, so it\n * is even MORE cwd-sensitive than OPTION 1 — it is anchored too. Never a SECOND `cd … &&`: the\n * allowlist matches the whole command and three segments are denied.\n */\n private fixOptions(): string[] {\n const anchor = (cmd: string): string => (this.cdOk ? `cd ${this.safeRoot} && ${cmd}` : cmd);\n return [\n ' Fix Option 1: (preferred) the only cure that repairs every managed surface, and it runs on a broken tree',\n ` run EXACTLY: '${anchor(UPGRADE_SHIM_CMD)}'`,\n ` Fix Option 2: PARTIAL - repairs ${SHIM_MARKER} only. Pick it ONLY when the installed @webpieces/ai-hook-rules is older than 0.4.408, where Fix Option 1 does not exist yet; then upgrade and run Fix Option 1.`,\n ` run EXACTLY: '${anchor(RESTORE_SHIM_CMD)}'`,\n ` NOT an option: do NOT use the bare '${INSTALL_HOOKS_CMD}' here - it also migrates your config and PROMPTS for a hook target twice, which hangs a non-interactive session.`,\n '',\n ];\n }\n\n private footer(): string[] {\n return [\n NO_CHAINING_RULE,\n `If you meant to remove @webpieces/ai-hook-rules, delete its hooks from .claude/settings.json rather than reverting ${SHIM_MARKER}.`,\n ];\n }\n}\n\n// The ONE entry point its two call sites (hook-core's fault-S deny, and the L0 fault table in\n// l0-matrix) import. The rendering lives on ShimStaleDeny above, per CLAUDE.md; this is the seam.\n// webpieces-disable no-function-outside-class -- one-line constructor+render seam for ShimStaleDeny, in the dependency-free shim module (it must stay callable from a tree too broken to build a DI container).\nexport function shimStaleDenyReason(installedVersion: string, root: string, drifted: readonly string[], inSubagent: boolean): string {\n return new ShimStaleDeny(installedVersion, root, drifted, inSubagent).render();\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const DRIFT_INVERSE_FIX_SH = "WP_BRANCH=\"$(git -C \"$ROOT\" branch --show-current 2>/dev/null)\"\n WP_PIN_EDIT=\"edit $ROOT/pnpm-workspace.yaml - the catalog line for $DRIFT_PKG, or that dependency in $ROOT/package.json if this repo pins directly - and set it to $DRIFT_INSTALLED, then run 'pnpm install'\"\n if [ -z \"$WP_BRANCH\" ]; then\n WP_FIX=\" Fix Option 1: (preferred) HEAD is DETACHED here, so a pin edit would belong to no branch - get onto main instead, whose pin is already at or ahead of what is installed, so the drift clears with no edit at all${NL} run EXACTLY: 'git checkout main && git pull origin main', then 'pnpm install'${NL} Fix Option 2: you mean to stay on this exact commit - the downgrade to $DRIFT_DECLARED is the point${NL} run EXACTLY: 'pnpm install'\"\n elif [ \"$WP_BRANCH\" = main ]; then\n WP_FIX=\" Fix Option 1: (preferred) go FORWARD - keep what is installed and raise the pin to match it${NL} ${WP_PIN_EDIT}${NL} That edit is ALLOWED while this block is up, and the install then only rewrites the lock - nothing is downgraded, because the pin now names what is already on disk.${NL} Fix Option 2: you are on main and want what origin pins instead${NL} run EXACTLY: 'git checkout main && git pull origin main', then 'pnpm install'\"\n else\n WP_FIX=\" Fix Option 1: (preferred) go FORWARD - keep what is installed and raise THIS branch's pin to match it${NL} ${WP_PIN_EDIT}${NL} That edit is ALLOWED while this block is up, and the install then only rewrites the lock - nothing is downgraded, because the pin now names what is already on disk.${NL} Fix Option 2: you mean to align node_modules to YOUR branch pin - that is a DOWNGRADE to $DRIFT_DECLARED, so pick it only if you meant to${NL} run EXACTLY: 'pnpm install'${NL} Do NOT reach for 'git pull origin main': pulling main into a feature branch destroys the fork point the build gate --base and the PR review diff are computed from, and the guards block it.\"\n fi";
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DRIFT_INVERSE_FIX_SH = void 0;
|
|
4
|
-
const l0_allowlist_1 = require("./l0-allowlist");
|
|
5
|
-
// ---------------------------------------------------------------------------
|
|
6
|
-
// Shell fragment: the Fix Options for the INVERSE half of L0 fault D — node_modules is NEWER than the
|
|
7
|
-
// pin (or the two could not be ordered), so a bare `pnpm install` is a DOWNGRADE.
|
|
8
|
-
//
|
|
9
|
-
// Its own module for the same reason shim-audit-log.ts is: shim.ts renders the whole shim body and is
|
|
10
|
-
// at its file-size cap. It imports FROM ./l0-allowlist and is never imported BY it, so the graph stays
|
|
11
|
-
// acyclic, and it stays as dependency-free as the rest of the shim — this text has to render on a tree
|
|
12
|
-
// too broken to load the rule engine.
|
|
13
|
-
//
|
|
14
|
-
// EVERY ARM'S FIRST OPTION NOW GOES FORWARD (2026-08-20). This message used to lead, on a feature
|
|
15
|
-
// branch, with `pnpm install` as "(preferred) ... usually right" — an option that is by construction a
|
|
16
|
-
// DOWNGRADE, since this whole branch of the message only renders when node_modules is the NEWER side.
|
|
17
|
-
// One measured agent took that advice, downgraded its engine two releases, and the older engine then
|
|
18
|
-
// rejected a config key it had never heard of and blocked every Bash call. The forward move — keep what
|
|
19
|
-
// is installed, raise the pin to match it — was never offered at all, on any arm.
|
|
20
|
-
//
|
|
21
|
-
// THE FORWARD MOVE IS A FILE EDIT, and that is exactly why it could not be offered before: editing
|
|
22
|
-
// pnpm-workspace.yaml was not on the L0 allowlist, so the guard would have prescribed a call it then
|
|
23
|
-
// denied. It IS on the list now (see l0-allowlist's manifest entry and isAllowed), so Option 1 is a
|
|
24
|
-
// cure the reader can actually perform from inside this block. The `pnpm install` that follows it
|
|
25
|
-
// rewrites the lock and downgrades nothing, because the pin now names what is already on disk.
|
|
26
|
-
//
|
|
27
|
-
// THIS FRAGMENT IS SINGLE-TREE ONLY. Fault D no longer fires when the guard bin was inherited from
|
|
28
|
-
// another tree (see VERSION_DRIFT_GUARD_SH) — that case belongs to L1 row 8, which can see all four
|
|
29
|
-
// versions. So every option here acts on ONE tree, and no cross-tree escalation is needed or offered.
|
|
30
|
-
//
|
|
31
|
-
// ON MAIN the alternative forward move is `git checkout main && git pull origin main` — it ends ON main,
|
|
32
|
-
// merges nothing into anything, is a no-op checkout when you are already there, and it is the ONE pull
|
|
33
|
-
// spelling still on the L0 allowlist (see CHECKOUT_MAIN_PULL_BODY_ERE, which also records why it is a
|
|
34
|
-
// narrow literal).
|
|
35
|
-
//
|
|
36
|
-
// RAW GIT ON PURPOSE, and this is now the DIFFERENCE from the workflow guards rather than a match with
|
|
37
|
-
// them. stale-main-bash-guard, merged-branch-message, TreeRecovery and the L2 rows all prescribe
|
|
38
|
-
// `pnpm wp-sync-main` — the same pairing with `wp-cleanup` and the orphan-directory sweep
|
|
39
|
-
// welded on, so the sweep actually runs. THIS message must NOT follow them: the fault it is reporting IS
|
|
40
|
-
// that `node_modules` disagrees with the pin, which makes `node_modules` the untrustworthy thing, and
|
|
41
|
-
// every `pnpm wp-*` bin resolves through it. An L0 cure may never be a command that has to load the
|
|
42
|
-
// package it is repairing. Two layers, two spellings, and that is not the two-spellings shim — they are
|
|
43
|
-
// cures for two different states, one of which has a working package manager and one of which does not.
|
|
44
|
-
//
|
|
45
|
-
// The rationale is recorded HERE, in the source, and deliberately NOT as a comment inside the rendered
|
|
46
|
-
// shell: the committed `.claude/webpieces/ai-hook.sh` is byte-compared against renderShim() by the
|
|
47
|
-
// committed-shim self-guard, so a comment-only change would fire that guard on every consumer's tree for
|
|
48
|
-
// no behavioural reason — the exact churn the version stamp was removed to stop.
|
|
49
|
-
//
|
|
50
|
-
// `git branch --show-current`, NOT `git rev-parse --abbrev-ref HEAD`: it answers on an UNBORN branch
|
|
51
|
-
// (`rev-parse` fatals there), and it prints an EMPTY string on a detached HEAD. That empty answer used
|
|
52
|
-
// to fall into the feature-branch half, which was wrong twice over: there is no branch for Option 1's
|
|
53
|
-
// pin edit to belong to, and the branch-specific warning about fork points is meaningless. It is its own
|
|
54
|
-
// arm now — the one arm whose preferred cure is the checkout, precisely because it has no branch to edit.
|
|
55
|
-
//
|
|
56
|
-
// CONSTRAINT, same as every other deny fragment: no `"` and no backslash may reach the rendered text —
|
|
57
|
-
// it is interpolated into a `REASON="…"` shell assignment and then printf'd into a JSON string.
|
|
58
|
-
// ---------------------------------------------------------------------------
|
|
59
|
-
const PIN_EDIT_SH = `edit $ROOT/${l0_allowlist_1.WORKSPACE_MANIFEST} - the catalog line for $DRIFT_PKG, or that dependency in `
|
|
60
|
-
+ `$ROOT/${l0_allowlist_1.PACKAGE_MANIFEST} if this repo pins directly - and set it to $DRIFT_INSTALLED, then run 'pnpm install'`;
|
|
61
|
-
const FORWARD_NOTE_SH = `That edit is ALLOWED while this block is up, and the install then only rewrites the lock - `
|
|
62
|
-
+ `nothing is downgraded, because the pin now names what is already on disk.`;
|
|
63
|
-
exports.DRIFT_INVERSE_FIX_SH = `WP_BRANCH="$(git -C "$ROOT" branch --show-current 2>/dev/null)"
|
|
64
|
-
WP_PIN_EDIT="${PIN_EDIT_SH}"
|
|
65
|
-
if [ -z "$WP_BRANCH" ]; then
|
|
66
|
-
WP_FIX=" Fix Option 1: (preferred) HEAD is DETACHED here, so a pin edit would belong to no branch - get onto main instead, whose pin is already at or ahead of what is installed, so the drift clears with no edit at all\${NL} run EXACTLY: '${l0_allowlist_1.CHECKOUT_MAIN_PULL_CMD}', then 'pnpm install'\${NL} Fix Option 2: you mean to stay on this exact commit - the downgrade to $DRIFT_DECLARED is the point\${NL} run EXACTLY: 'pnpm install'"
|
|
67
|
-
elif [ "$WP_BRANCH" = main ]; then
|
|
68
|
-
WP_FIX=" Fix Option 1: (preferred) go FORWARD - keep what is installed and raise the pin to match it\${NL} \${WP_PIN_EDIT}\${NL} ${FORWARD_NOTE_SH}\${NL} Fix Option 2: you are on main and want what origin pins instead\${NL} run EXACTLY: '${l0_allowlist_1.CHECKOUT_MAIN_PULL_CMD}', then 'pnpm install'"
|
|
69
|
-
else
|
|
70
|
-
WP_FIX=" Fix Option 1: (preferred) go FORWARD - keep what is installed and raise THIS branch's pin to match it\${NL} \${WP_PIN_EDIT}\${NL} ${FORWARD_NOTE_SH}\${NL} Fix Option 2: you mean to align node_modules to YOUR branch pin - that is a DOWNGRADE to $DRIFT_DECLARED, so pick it only if you meant to\${NL} run EXACTLY: 'pnpm install'\${NL} Do NOT reach for 'git pull origin main': pulling main into a feature branch destroys the fork point the build gate --base and the PR review diff are computed from, and the guards block it."
|
|
71
|
-
fi`;
|
|
72
|
-
//# sourceMappingURL=shim-drift-fix.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shim-drift-fix.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/shim-drift-fix.ts"],"names":[],"mappings":";;;AAAA,iDAA8F;AAE9F,8EAA8E;AAC9E,sGAAsG;AACtG,kFAAkF;AAClF,EAAE;AACF,sGAAsG;AACtG,uGAAuG;AACvG,uGAAuG;AACvG,sCAAsC;AACtC,EAAE;AACF,kGAAkG;AAClG,uGAAuG;AACvG,sGAAsG;AACtG,qGAAqG;AACrG,wGAAwG;AACxG,kFAAkF;AAClF,EAAE;AACF,mGAAmG;AACnG,qGAAqG;AACrG,oGAAoG;AACpG,kGAAkG;AAClG,+FAA+F;AAC/F,EAAE;AACF,mGAAmG;AACnG,oGAAoG;AACpG,sGAAsG;AACtG,EAAE;AACF,yGAAyG;AACzG,uGAAuG;AACvG,sGAAsG;AACtG,mBAAmB;AACnB,EAAE;AACF,uGAAuG;AACvG,iGAAiG;AACjG,0FAA0F;AAC1F,yGAAyG;AACzG,sGAAsG;AACtG,oGAAoG;AACpG,wGAAwG;AACxG,wGAAwG;AACxG,EAAE;AACF,uGAAuG;AACvG,mGAAmG;AACnG,yGAAyG;AACzG,iFAAiF;AACjF,EAAE;AACF,qGAAqG;AACrG,uGAAuG;AACvG,sGAAsG;AACtG,yGAAyG;AACzG,0GAA0G;AAC1G,EAAE;AACF,uGAAuG;AACvG,gGAAgG;AAChG,8EAA8E;AAC9E,MAAM,WAAW,GACb,cAAc,iCAAkB,4DAA4D;MAC1F,SAAS,+BAAgB,uFAAuF,CAAC;AAEvH,MAAM,eAAe,GACjB,6FAA6F;MAC3F,2EAA2E,CAAC;AAErE,QAAA,oBAAoB,GAAG;mBACjB,WAAW;;0PAE4N,qCAAsB;;gJAEhI,eAAe,kGAAkG,qCAAsB;;0JAE7H,eAAe;OAClK,CAAC","sourcesContent":["import { CHECKOUT_MAIN_PULL_CMD, WORKSPACE_MANIFEST, PACKAGE_MANIFEST } from './l0-allowlist';\n\n// ---------------------------------------------------------------------------\n// Shell fragment: the Fix Options for the INVERSE half of L0 fault D — node_modules is NEWER than the\n// pin (or the two could not be ordered), so a bare `pnpm install` is a DOWNGRADE.\n//\n// Its own module for the same reason shim-audit-log.ts is: shim.ts renders the whole shim body and is\n// at its file-size cap. It imports FROM ./l0-allowlist and is never imported BY it, so the graph stays\n// acyclic, and it stays as dependency-free as the rest of the shim — this text has to render on a tree\n// too broken to load the rule engine.\n//\n// EVERY ARM'S FIRST OPTION NOW GOES FORWARD (2026-08-20). This message used to lead, on a feature\n// branch, with `pnpm install` as \"(preferred) ... usually right\" — an option that is by construction a\n// DOWNGRADE, since this whole branch of the message only renders when node_modules is the NEWER side.\n// One measured agent took that advice, downgraded its engine two releases, and the older engine then\n// rejected a config key it had never heard of and blocked every Bash call. The forward move — keep what\n// is installed, raise the pin to match it — was never offered at all, on any arm.\n//\n// THE FORWARD MOVE IS A FILE EDIT, and that is exactly why it could not be offered before: editing\n// pnpm-workspace.yaml was not on the L0 allowlist, so the guard would have prescribed a call it then\n// denied. It IS on the list now (see l0-allowlist's manifest entry and isAllowed), so Option 1 is a\n// cure the reader can actually perform from inside this block. The `pnpm install` that follows it\n// rewrites the lock and downgrades nothing, because the pin now names what is already on disk.\n//\n// THIS FRAGMENT IS SINGLE-TREE ONLY. Fault D no longer fires when the guard bin was inherited from\n// another tree (see VERSION_DRIFT_GUARD_SH) — that case belongs to L1 row 8, which can see all four\n// versions. So every option here acts on ONE tree, and no cross-tree escalation is needed or offered.\n//\n// ON MAIN the alternative forward move is `git checkout main && git pull origin main` — it ends ON main,\n// merges nothing into anything, is a no-op checkout when you are already there, and it is the ONE pull\n// spelling still on the L0 allowlist (see CHECKOUT_MAIN_PULL_BODY_ERE, which also records why it is a\n// narrow literal).\n//\n// RAW GIT ON PURPOSE, and this is now the DIFFERENCE from the workflow guards rather than a match with\n// them. stale-main-bash-guard, merged-branch-message, TreeRecovery and the L2 rows all prescribe\n// `pnpm wp-sync-main` — the same pairing with `wp-cleanup` and the orphan-directory sweep\n// welded on, so the sweep actually runs. THIS message must NOT follow them: the fault it is reporting IS\n// that `node_modules` disagrees with the pin, which makes `node_modules` the untrustworthy thing, and\n// every `pnpm wp-*` bin resolves through it. An L0 cure may never be a command that has to load the\n// package it is repairing. Two layers, two spellings, and that is not the two-spellings shim — they are\n// cures for two different states, one of which has a working package manager and one of which does not.\n//\n// The rationale is recorded HERE, in the source, and deliberately NOT as a comment inside the rendered\n// shell: the committed `.claude/webpieces/ai-hook.sh` is byte-compared against renderShim() by the\n// committed-shim self-guard, so a comment-only change would fire that guard on every consumer's tree for\n// no behavioural reason — the exact churn the version stamp was removed to stop.\n//\n// `git branch --show-current`, NOT `git rev-parse --abbrev-ref HEAD`: it answers on an UNBORN branch\n// (`rev-parse` fatals there), and it prints an EMPTY string on a detached HEAD. That empty answer used\n// to fall into the feature-branch half, which was wrong twice over: there is no branch for Option 1's\n// pin edit to belong to, and the branch-specific warning about fork points is meaningless. It is its own\n// arm now — the one arm whose preferred cure is the checkout, precisely because it has no branch to edit.\n//\n// CONSTRAINT, same as every other deny fragment: no `\"` and no backslash may reach the rendered text —\n// it is interpolated into a `REASON=\"…\"` shell assignment and then printf'd into a JSON string.\n// ---------------------------------------------------------------------------\nconst PIN_EDIT_SH =\n `edit $ROOT/${WORKSPACE_MANIFEST} - the catalog line for $DRIFT_PKG, or that dependency in `\n + `$ROOT/${PACKAGE_MANIFEST} if this repo pins directly - and set it to $DRIFT_INSTALLED, then run 'pnpm install'`;\n\nconst FORWARD_NOTE_SH =\n `That edit is ALLOWED while this block is up, and the install then only rewrites the lock - `\n + `nothing is downgraded, because the pin now names what is already on disk.`;\n\nexport const DRIFT_INVERSE_FIX_SH = `WP_BRANCH=\"$(git -C \"$ROOT\" branch --show-current 2>/dev/null)\"\n WP_PIN_EDIT=\"${PIN_EDIT_SH}\"\n if [ -z \"$WP_BRANCH\" ]; then\n WP_FIX=\" Fix Option 1: (preferred) HEAD is DETACHED here, so a pin edit would belong to no branch - get onto main instead, whose pin is already at or ahead of what is installed, so the drift clears with no edit at all\\${NL} run EXACTLY: '${CHECKOUT_MAIN_PULL_CMD}', then 'pnpm install'\\${NL} Fix Option 2: you mean to stay on this exact commit - the downgrade to $DRIFT_DECLARED is the point\\${NL} run EXACTLY: 'pnpm install'\"\n elif [ \"$WP_BRANCH\" = main ]; then\n WP_FIX=\" Fix Option 1: (preferred) go FORWARD - keep what is installed and raise the pin to match it\\${NL} \\${WP_PIN_EDIT}\\${NL} ${FORWARD_NOTE_SH}\\${NL} Fix Option 2: you are on main and want what origin pins instead\\${NL} run EXACTLY: '${CHECKOUT_MAIN_PULL_CMD}', then 'pnpm install'\"\n else\n WP_FIX=\" Fix Option 1: (preferred) go FORWARD - keep what is installed and raise THIS branch's pin to match it\\${NL} \\${WP_PIN_EDIT}\\${NL} ${FORWARD_NOTE_SH}\\${NL} Fix Option 2: you mean to align node_modules to YOUR branch pin - that is a DOWNGRADE to $DRIFT_DECLARED, so pick it only if you meant to\\${NL} run EXACTLY: 'pnpm install'\\${NL} Do NOT reach for 'git pull origin main': pulling main into a feature branch destroys the fork point the build gate --base and the PR review diff are computed from, and the guards block it.\"\n fi`;\n"]}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The shim's PreToolUse deny payload, as it prints it on stdout. Named (not an inline literal on the
|
|
3
|
-
* JSON.parse cast) so the wire shape this testkit depends on is stated once, in one place.
|
|
4
|
-
*/
|
|
5
|
-
export declare class HookSpecificOutput {
|
|
6
|
-
readonly permissionDecisionReason: string;
|
|
7
|
-
constructor(permissionDecisionReason: string);
|
|
8
|
-
}
|
|
9
|
-
/** The decision envelope wrapping {@link HookSpecificOutput}. */
|
|
10
|
-
export declare class PreToolUseDecision {
|
|
11
|
-
readonly hookSpecificOutput: HookSpecificOutput;
|
|
12
|
-
constructor(hookSpecificOutput: HookSpecificOutput);
|
|
13
|
-
}
|
|
14
|
-
/** The outcome of one shim invocation. Data-only → a class, per CLAUDE.md. */
|
|
15
|
-
export declare class ShimRun {
|
|
16
|
-
readonly status: number | null;
|
|
17
|
-
readonly stdout: string;
|
|
18
|
-
readonly stderr: string;
|
|
19
|
-
constructor(status: number | null, stdout: string, stderr: string);
|
|
20
|
-
/** True when the shim emitted a PreToolUse deny. */
|
|
21
|
-
isDenied(): boolean;
|
|
22
|
-
/**
|
|
23
|
-
* The deny REASON, parsed out of the PreToolUse JSON.
|
|
24
|
-
* @throws if this run was not a deny (there is no reason to read).
|
|
25
|
-
*/
|
|
26
|
-
denyReason(): string;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* ShimTestkit — the shared harness for driving the rendered shim through a REAL /bin/sh.
|
|
30
|
-
*
|
|
31
|
-
* Extracted so setup.spec.ts and shim-drift.spec.ts drive the shim the SAME way instead of each
|
|
32
|
-
* keeping its own copy: the shim's entire contract is "what /bin/sh actually does with it", so two
|
|
33
|
-
* drifting harnesses would silently become two different contracts.
|
|
34
|
-
*
|
|
35
|
-
* An instance class (not module-scope functions) because this is normal source to the linter — only
|
|
36
|
-
* *.spec.ts is exempt from no-function-outside-class, and a testkit should not need a disable comment
|
|
37
|
-
* to exist.
|
|
38
|
-
*/
|
|
39
|
-
export declare class ShimTestkit {
|
|
40
|
-
/** A throwaway repo root under the OS temp dir. */
|
|
41
|
-
mktmp(): string;
|
|
42
|
-
/**
|
|
43
|
-
* Run the rendered shim exactly as Claude Code would: `sh <shim> <bin> ...`, from a repo cwd,
|
|
44
|
-
* piping tool-payload JSON on stdin. spawnSync never throws on non-zero exit.
|
|
45
|
-
*/
|
|
46
|
-
runShim(root: string, bin: string, stdin: string): ShimRun;
|
|
47
|
-
/**
|
|
48
|
-
* A repo root staged so the shim's VERSION-DRIFT check (fault D) fires: an installed guard bin, a
|
|
49
|
-
* declared @webpieces/pr-gate pin in package.json, and a different installed version in
|
|
50
|
-
* node_modules. The fake bin prints EXECED, so "the guards actually ran" is observable in stdout —
|
|
51
|
-
* pass matching versions to stage the no-drift case instead.
|
|
52
|
-
*
|
|
53
|
-
* Lives here rather than in one spec because two spec files now need the identical staging, and a
|
|
54
|
-
* second copy is a second definition of what "drift" means.
|
|
55
|
-
*/
|
|
56
|
-
stageDriftRoot(declared: string, installed: string): string;
|
|
57
|
-
/**
|
|
58
|
-
* Make `root` a real git repo whose CURRENT BRANCH is `branch`, and return it.
|
|
59
|
-
*
|
|
60
|
-
* The fault-D deny asks `git branch --show-current` to decide whether "move forward to what origin
|
|
61
|
-
* pins" is a legal command here (it is on main, and it destroys the fork point on a feature branch),
|
|
62
|
-
* so the branch is now an INPUT to the message and has to be stageable. `symbolic-ref` rather than a
|
|
63
|
-
* commit: `--show-current` answers on an UNBORN branch, so this needs no user identity, no index and
|
|
64
|
-
* no object write — which is also why a staged root with NO git dir at all keeps answering '' and
|
|
65
|
-
* lands on the conservative, non-main half.
|
|
66
|
-
*/
|
|
67
|
-
stageBranch(root: string, branch: string): string;
|
|
68
|
-
/**
|
|
69
|
-
* A repo root that DECLARES @webpieces/ai-hook-rules but has nothing installed — fault X, the
|
|
70
|
-
* ordinary fresh-clone / new-worktree case whose cure really is `pnpm install`.
|
|
71
|
-
*
|
|
72
|
-
* A bare mktmp() root is NOT this case, and that distinction is the whole point of fault U: with no
|
|
73
|
-
* package.json at all, nothing asks for the package and `pnpm install` is a no-op. Every X spec must
|
|
74
|
-
* stage the declaration explicitly, or it silently asserts against the U message instead.
|
|
75
|
-
*/
|
|
76
|
-
stageDeclaredRoot(declared?: string): string;
|
|
77
|
-
/**
|
|
78
|
-
* A throwaway repo root that OWNS a committed shim at shimPath(root) with the given contents
|
|
79
|
-
* (null = no shim at all, i.e. a fresh clone / global install). Shared by the two spec files that
|
|
80
|
-
* exercise the committed-shim self-guard, so "a root with a shim in it" has one definition.
|
|
81
|
-
*/
|
|
82
|
-
stageCommittedShim(content: string | null): string;
|
|
83
|
-
/** A Bash tool payload, as Claude Code sends it on stdin. */
|
|
84
|
-
bashPayload(command: string): string;
|
|
85
|
-
/** A Read payload — the L0 allowlist entry that keeps a broken tree inspectable. */
|
|
86
|
-
readPayload(filePath: string): string;
|
|
87
|
-
/** A file-tool payload, for the always-allowed webpieces.config.json recovery target. */
|
|
88
|
-
filePayload(toolName: string, filePath: string): string;
|
|
89
|
-
/** True when `cmd` matches a POSIX ERE, judged by the SAME `grep -E` the shim itself runs. */
|
|
90
|
-
ereMatches(ere: string, cmd: string): boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Which of `cmds` that same `grep -E` matches — answered in ONE grep process for the whole batch.
|
|
93
|
-
*
|
|
94
|
-
* grep is a line matcher, so feeding N commands as N lines asks exactly the question `-Eq` answers
|
|
95
|
-
* per command; the engine, the ERE and the anchors are unchanged. What changes is cost: a process
|
|
96
|
-
* spawn is ~5ms on an idle machine but ~100ms when the suite runs projects in parallel, so a
|
|
97
|
-
* 16-command twin check used to be 16 spawns (~2s of pure spawn latency) for one grep pass. That
|
|
98
|
-
* is what made these files miss the per-test timeout under load.
|
|
99
|
-
*/
|
|
100
|
-
ereMatchSet(ere: string, cmds: readonly string[]): EreMatchSet;
|
|
101
|
-
}
|
|
102
|
-
/** The lines `grep -E` matched in one batched run — ask it per command with {@link matched}. */
|
|
103
|
-
export declare class EreMatchSet {
|
|
104
|
-
private readonly hits;
|
|
105
|
-
constructor(hits: ReadonlySet<string>);
|
|
106
|
-
matched(cmd: string): boolean;
|
|
107
|
-
}
|