@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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"setup-config.js","sourceRoot":"","sources":["../../../../../../packages/tooling/ai-hook-rules/src/bin/setup-config.ts"],"names":[],"mappings":";;AA6SA,0BAqEC;AAUD,4CAgBC;;AA5YD,+CAAyB;AACzB,mDAA6B;AAE7B,0DAGiC;AAEjC,+CAA2C;AAE3C;;;;;;;;;;;GAWG;AACH,MAAM,eAAe,GAAG,uBAAuB,CAAC;AAChD,sGAAsG;AACtG,oGAAoG;AACpG,iGAAiG;AACjG,wFAAwF;AACxF,MAAM,iBAAiB,GAAG,yBAAyB,CAAC;AACpD,MAAM,sBAAsB,GAAG,0BAA0B,CAAC;AAwB1D,oIAAoI;AACpI,SAAS,QAAQ,CAAC,QAAgB;IAC9B,4FAA4F;IAC5F,2FAA2F;IAC3F,EAAE;IACF,gGAAgG;IAChG,2FAA2F;IAC3F,kGAAkG;IAClG,iGAAiG;IACjG,+FAA+F;IAC/F,6FAA6F;IAC7F,kGAAkG;IAClG,OAAO,IAAA,+BAAgB,EAAC,QAAQ,CAAC,CAAC;AACtC,CAAC;AAED,wGAAwG;AACxG,yGAAyG;AACzG,yCAAyC;AACzC,4NAA4N;AAC5N,S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,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3D,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC7B,WAAW,CAAC,UAAU,EAAE,eAAe,EAAE,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,wBAAwB,eAAe,4IAA4I,CAAC,CAAC;QACjM,OAAO,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;QAC9D,OAAO;IACX,CAAC;IACD,MAAM,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;IAC/C,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,gBAAgB,eAAe,sEAAsE,CAAC,CAAC;QACnH,OAAO;IACX,CAAC;IACD,WAAW,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;IACvC,OAAO,CAAC,GAAG,CAAC,yBAAyB,eAAe,GAAG,CAAC,CAAC;IACzD,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO;QAAE,OAAO,CAAC,GAAG,CAAC,SAAS,MAAM,EAAE,CAAC,CAAC;AACxE,CAAC","sourcesContent":["import * as fs from 'fs';\nimport * as path from 'path';\n\nimport {\n allRuleNames, seedEntryForRule, schemaFieldNames, sectionForRule, isHookGuard, DEFAULT_MATCH_RULES,\n DEFAULT_BUILD_COMMAND, RETIRED_CONFIG_KEYS, RETIRED_SCOPE_RULE,\n} from '@webpieces/rules-config';\n\nimport { toError } from '../core/to-error';\n\n/**\n * SEEDING AND MIGRATING `webpieces.config.json` — the installer's OTHER job.\n *\n * Split out of ./setup.ts purely for size, and along the seam that was already there: setup.ts is now\n * hook WIRING (which settings file gets which matcher and which shim command) and this module is CONFIG\n * SHAPE (which rules exist, where a retired key moves to). They share only `main()`, which calls this\n * once and then wires the hooks.\n *\n * Like setup.ts it is deliberately DI-FREE: `wp-install-ai-hooks` has to run on a half-written\n * node_modules (see install-entry.ts), so every function here is module-scope and imports nothing that\n * needs a container.\n */\nconst CONFIG_FILENAME = 'webpieces.config.json';\n// The seeded buildCommand comes from @webpieces/rules-config, NOT from a copy here. This file used to\n// hold its own — with `--base=origin/main`, a DIFFERENT base from the one the gate documents — so a\n// freshly set-up repo was seeded with a command that rebuilds projects touched by other people's\n// merged PRs, and whole-repo-build-guard then quoted that command back in its refusals.\nconst DEFAULT_UPSERT_PR = 'pnpm wp-start-upsert-pr';\nconst DEFAULT_MERGE_COMPLETE = 'pnpm wp-finish-upsert-pr';\n// ---------------------------------------------------------------------------\n// webpieces.config.json seeding + migration to the rules / hookGuards / commands layout.\n// ---------------------------------------------------------------------------\n// webpieces-disable no-any-unknown -- webpieces.config.json / settings.json are opaque consumer JSON\ntype Json = Record<string, unknown>;\ntype RuleEntry = Json;\ntype Section = Record<string, RuleEntry>;\n\ninterface ConfigFile {\n extends?: string;\n rules: Section;\n hookGuards: Section;\n commands: Json;\n excludePaths: string[];\n 'match-rules': Json[];\n rulesDir: string[];\n}\n\ninterface MigrateResult {\n config: ConfigFile;\n changes: string[];\n}\n\n// webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design\nfunction seedRule(ruleName: string): RuleEntry {\n // Both escape hatches are seeded (and REQUIRED) so every rule block shows them: 0 = active,\n // null = no branch scoping. A human/AI edits these to time-box or branch-scope a rule off.\n //\n // The ENTIRE entry comes from rules-config's seedEntryForRule() — the same module that owns the\n // schema the loader validates against, so the installer can never emit an entry the loader\n // rejects. It supplies: the recommended mode (the SAME recommendation the validator prints in its\n // copy-paste snippet, so seed and advice cannot disagree), both hatches, and a default for every\n // other schema-REQUIRED field. Seeding used to be a flat 'OFF' plus the two hatches, which was\n // wrong twice over: adopters got nothing enforced, AND the entry was missing required fields\n // (e.g. branch-creation-guard.autoReapMergedBranches), so the config failed to load on first run.\n return seedEntryForRule(ruleName);\n}\n\n// The guard-hint command strings live under `guardHints`. The flat `upsertPr`/`mergeComplete` keys this\n// used to seed are RETIRED and now fail validation — seeding them meant every freshly installed repo was\n// born on a shape the validator rejects.\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction seedCommands(): Json {\n return {\n 'pr-gate': { mode: 'OFF', buildCommand: DEFAULT_BUILD_COMMAND, gates: [] },\n guardHints: { prCreationOrPush: DEFAULT_UPSERT_PR, mergeInProgress: DEFAULT_MERGE_COMPLETE },\n };\n}\n\n// Required excludePaths block: ONE glob list suppressing hook enforcement per file path. Seeded empty\n// (enforce everywhere) — a client adds paths (e.g. \"repositories/**\") to exempt vendored trees.\n//\n// Deliberately NOT seeded with webpieces' own `.webpieces/` state dir. That exemption lives in CODE\n// (`isWebpiecesStateDir`, consulted by `filterByExcludedPaths` ahead of this list and regardless of it),\n// and a glob here would be a second, weaker spelling of it — weaker because `.webpieces/**` compiles to\n// an anchored regex that misses the bare directory the predicate matches, and because a config entry\n// invites a consumer to delete it and believe the exemption went with it.\n// webpieces-disable no-function-outside-class -- sibling of the other seed* helpers; this module is config-shape builders by design\nfunction seedExcludePaths(): string[] {\n return [];\n}\n\n// Bring an existing `excludePaths` forward to the single-list shape. Already a list → untouched.\n// Legacy `{ rules, guards }` → unioned (order preserved, duplicates dropped) and recorded as a change\n// so `wp-install-ai-hooks` is the migration path rather than a hand-edit. Anything else → seeded [].\n// webpieces-disable no-any-unknown -- `raw` is opaque consumer JSON until narrowed here\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateExcludePaths(raw: unknown, changes: string[]): string[] {\n if (Array.isArray(raw)) return (raw as string[]).filter(p => typeof p === 'string');\n if (typeof raw === 'object' && raw !== null) {\n // webpieces-disable no-any-unknown -- narrowing the opaque legacy block from consumer JSON\n const legacy = raw as Record<string, unknown>;\n const rules = Array.isArray(legacy['rules']) ? (legacy['rules'] as string[]) : [];\n const guards = Array.isArray(legacy['guards']) ? (legacy['guards'] as string[]) : [];\n const merged = [...new Set([...rules, ...guards].filter(p => typeof p === 'string'))];\n changes.push(`migrated excludePaths {rules,guards} -> one list (${merged.length} path(s))`);\n return merged;\n }\n changes.push('added excludePaths ([])');\n return seedExcludePaths();\n}\n\n/** One retired flat command string and the guardHints field it becomes. Data-only (per CLAUDE.md). */\nclass GuardHintMove {\n retiredKey: string;\n hintKey: string;\n fallback: string;\n\n constructor(retiredKey: string, hintKey: string, fallback: string) {\n this.retiredKey = retiredKey;\n this.hintKey = hintKey;\n this.fallback = fallback;\n }\n}\n\n/**\n * Bring `commands` forward to the `guardHints` shape, moving the RETIRED flat `upsertPr`/`mergeComplete`\n * strings and DELETING them. Deleting is the point: the validator now rejects them, so leaving them behind\n * would keep the config failing after a \"successful\" sync.\n *\n * The consumer's own value wins over the default — a repo that renamed its gated command keeps that name.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateGuardHints(commands: Json, changes: string[]): void {\n const hints: Json = (typeof commands['guardHints'] === 'object' && commands['guardHints'] !== null)\n ? (commands['guardHints'] as Json) : {};\n const moves: readonly GuardHintMove[] = [\n new GuardHintMove('upsertPr', 'prCreationOrPush', DEFAULT_UPSERT_PR),\n new GuardHintMove('mergeComplete', 'mergeInProgress', DEFAULT_MERGE_COMPLETE),\n ];\n for (const move of moves) {\n const retiredKey = move.retiredKey;\n const hintKey = move.hintKey;\n const fallback = move.fallback;\n const carried = commands[retiredKey];\n if (carried !== undefined) {\n delete commands[retiredKey];\n if (hints[hintKey] === undefined) hints[hintKey] = carried;\n changes.push(`moved retired commands.${retiredKey} -> commands.guardHints.${hintKey}`);\n }\n if (hints[hintKey] === undefined) {\n hints[hintKey] = fallback;\n changes.push(`added commands.guardHints.${hintKey}`);\n }\n }\n commands['guardHints'] = hints;\n}\n\n/**\n * Apply the RETIRED rule/guard retirements in place. These used to be rewritten silently at load time, so\n * a consumer's file kept the dead name forever; the loader now rejects it, which makes this the one\n * command that can fix the file. Skips a rename when the new name is already configured, so an explicit\n * entry is never clobbered by a stale one.\n *\n * NOT EVERY RETIREMENT IS A RENAME, and treating them all as one produced garbage. `whole-repo-build-guard`\n * moved OUT of webpieces.config.json entirely — its `movedTo` is the PROSE destination\n * `~/.webpieces/config.json → experimental.whole-repo-build-guard`, not a sibling key — so the rename\n * branch below would have created a hookGuards entry literally named that whole sentence, which no\n * validator knows and which the next run reports as another unknown rule. `prunable` is the discriminator:\n * when the entry says deleting is the whole fix, DELETE it, exactly as `ConfigPruner` does.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction migrateRetiredRuleNames(section: Section, changes: string[]): void {\n for (const entry of RETIRED_CONFIG_KEYS) {\n if (entry.scope !== RETIRED_SCOPE_RULE) continue;\n if (!(entry.key in section)) continue;\n if (entry.prunable) {\n delete section[entry.key];\n changes.push(`deleted retired \"${entry.key}\" (it moved to ${entry.movedTo})`);\n continue;\n }\n mergeIntoDestination(section, entry.key, entry.movedTo, changes);\n }\n fillRequiredFields(section, changes);\n}\n\n/**\n * Fold one retired key's entry into its destination, whether the destination exists yet or not.\n *\n * THIS IS N→1, NOT 1:1, and the difference is the whole reason this helper exists. Four retired keys\n * now point at ONE destination (`branch-state-guard`, `pr-lifecycle-guard`). The previous code renamed\n * the first key it met and then, finding the destination already present, DELETED each of the other\n * three outright — so which guard's settings survived depended on RETIRED_CONFIG_KEYS declaration\n * order rather than on the consumer's file, and the survivor carried only that one guard's fields, so\n * it was missing required fields of the merged schema. `wp-install-ai-hooks` is the command advertised\n * as the migration path; half-migrating every consumer into an invalid config is not an option.\n *\n * UNION, first writer wins per field. Earlier-declared keys are the more specific ones (only\n * feature-branch-guard carries `branchNamingConvention`), and a field already present on the\n * destination — because the consumer wrote it, or an earlier key contributed it — is never overwritten.\n * Fields the merged schema does not know are dropped by the same pass, since carrying a deleted field\n * across (`upsertPrCommand`) would produce a config the validator immediately rejects.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction mergeIntoDestination(section: Section, key: string, destination: string, changes: string[]): void {\n const source = asSection(section[key]);\n delete section[key];\n const fields = schemaFieldNames(destination);\n const target = asSection(section[destination]);\n const existed = destination in section;\n const carried: string[] = [];\n const dropped: string[] = [];\n for (const field of Object.keys(source)) {\n if (fields !== null && !fields.includes(field)) { dropped.push(field); continue; }\n if (field in target) continue;\n target[field] = source[field];\n carried.push(field);\n }\n section[destination] = target;\n const verb = existed ? 'merged' : 'renamed';\n const droppedNote = dropped.length > 0 ? `; dropped deleted field(s) ${dropped.join(', ')}` : '';\n changes.push(`${verb} retired \"${key}\" -> \"${destination}\" (carried ${carried.join(', ') || 'nothing new'}${droppedNote})`);\n}\n\n/**\n * Fill any schema-REQUIRED field a migrated entry ended up without.\n *\n * A union of four partial entries is not guaranteed to satisfy the destination's schema — the merged\n * `branch-state-guard` needs `mode` and both escape hatches, and a consumer whose four old entries\n * predate one of them would land short. Seeding the gap from the SAME source the installer and the\n * validator use (seedEntryForRule) is what makes the install command a complete instruction\n * rather than a first step. Only ever ADDS; a value the consumer stated is never touched.\n */\n// webpieces-disable no-function-outside-class -- sibling of the other seed*/migrate* helpers; this module is config-shape builders by design\nfunction fillRequiredFields(section: Section, changes: string[]): void {\n for (const name of Object.keys(section)) {\n if (schemaFieldNames(name) === null) continue;\n // A rule ENTRY is a flat bag of scalars, so it is read as Json here rather than through\n // asSection (whose values are whole entries). Same object either way; only the view differs.\n const entry: Json = asSection(section[name]);\n const seed = seedEntryForRule(name);\n const added: string[] = [];\n for (const field of Object.keys(seed)) {\n if (field in entry) continue;\n entry[field] = seed[field];\n added.push(field);\n }\n if (added.length === 0) continue;\n section[name] = entry;\n changes.push(`filled required field(s) on \"${name}\": ${added.join(', ')}`);\n }\n}\n\n// Deep-copy the framework's default match-rules (the no-fetch guard) into plain JSON for the config\n// file. Round-tripping through JSON turns the MatchRuleConfig instances into plain objects.\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction seedMatchRules(): Json[] {\n return JSON.parse(JSON.stringify(DEFAULT_MATCH_RULES)) as Json[];\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction buildSeedConfig(): ConfigFile {\n const rules: Section = {};\n const hookGuards: Section = {};\n for (const name of allRuleNames()) {\n if (sectionForRule(name) === 'hookGuards') hookGuards[name] = seedRule(name);\n else rules[name] = seedRule(name);\n }\n return {\n rules, hookGuards, commands: seedCommands(), excludePaths: seedExcludePaths(),\n // Seed the required match-rules array with the framework's default no-fetch guard. A fresh\n // project gets contract-first enforcement out of the box; clients edit it and add more entries.\n 'match-rules': seedMatchRules(),\n rulesDir: [],\n };\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction writeConfig(configPath: string, config: ConfigFile): void {\n fs.writeFileSync(configPath, JSON.stringify(config, null, 4) + '\\n');\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction readConfig(configPath: string): Json {\n const raw = fs.readFileSync(configPath, 'utf8');\n // eslint-disable-next-line @webpieces/no-unmanaged-exceptions\n try {\n return JSON.parse(raw) as Json;\n } catch (err: unknown) {\n const error = toError(err);\n throw new Error(`${CONFIG_FILENAME} has invalid JSON — fix it, then retry: ${error.message}`, { cause: error });\n }\n}\n\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nfunction asSection(value: Json[string]): Section {\n return (typeof value === 'object' && value !== null && !Array.isArray(value)) ? (value as Section) : {};\n}\n\n// Migrate an existing config to the rules / hookGuards / commands layout and add any missing rules.\n// Returns a human-readable list of what changed (empty = already up to date).\n// webpieces-disable no-function-outside-class -- this module is deliberately DI-FREE: `wp-install-ai-hooks` must run on a half-written node_modules (see install-entry.ts), so it cannot build a container to hold a method\nexport function migrate(existing: Json): MigrateResult {\n const changes: string[] = [];\n const rules: Section = asSection(existing['rules']);\n const hookGuards: Section = asSection(existing['hookGuards']);\n const commands: Json = (typeof existing['commands'] === 'object' && existing['commands'] !== null)\n ? (existing['commands'] as Json) : {};\n\n // Move a deprecated top-level pr-gate block under commands.\n if (existing['pr-gate'] !== undefined && commands['pr-gate'] === undefined) {\n commands['pr-gate'] = existing['pr-gate'];\n changes.push('moved top-level \"pr-gate\" → commands[\"pr-gate\"]');\n }\n // Apply retired RENAMES first, so a renamed guard is placed and presence-checked under its new name\n // rather than being treated as unknown and re-added alongside its own stale entry.\n migrateRetiredRuleNames(rules, changes);\n migrateRetiredRuleNames(hookGuards, changes);\n\n // Move guards mistakenly left in rules into hookGuards.\n for (const name of Object.keys(rules)) {\n if (isHookGuard(name)) {\n hookGuards[name] = rules[name];\n delete rules[name];\n changes.push(`moved \"${name}\" from rules → hookGuards`);\n }\n }\n // Move code rules mistakenly placed in hookGuards back into rules.\n for (const name of Object.keys(hookGuards)) {\n if (!isHookGuard(name) && allRuleNames().includes(name)) {\n rules[name] = hookGuards[name];\n delete hookGuards[name];\n changes.push(`moved \"${name}\" from hookGuards → rules`);\n }\n }\n // Add any missing built-in into its correct section, ENFORCING at its recommended mode (not OFF).\n for (const name of allRuleNames()) {\n const target = sectionForRule(name) === 'hookGuards' ? hookGuards : rules;\n if (!(name in target)) {\n const entry = seedRule(name);\n target[name] = entry;\n changes.push(`added \"${name}\" (${String(entry['mode'])}) to ${sectionForRule(name)}`);\n }\n }\n // Fill command defaults.\n if (commands['pr-gate'] === undefined) {\n commands['pr-gate'] = { mode: 'OFF', buildCommand: DEFAULT_BUILD_COMMAND, gates: [] };\n changes.push('added commands[\"pr-gate\"] (OFF)');\n }\n migrateGuardHints(commands, changes);\n\n // Seed the now-required excludePaths list (empty = enforce everywhere) if the config predates it,\n // and MIGRATE the legacy `{ rules: [], guards: [] }` object to the single list by unioning them.\n // The union is behaviour-preserving for every config we have seen (both lists set identically), and\n // widening is the safe direction anyway: a path either side excluded stays excluded.\n const excludePaths: string[] = migrateExcludePaths(existing['excludePaths'], changes);\n\n // Seed the now-required match-rules array (with the default no-fetch guard) if the config predates\n // it. A client that has already customized it keeps their array untouched.\n let matchRules: Json[];\n if (Array.isArray(existing['match-rules'])) {\n matchRules = existing['match-rules'] as Json[];\n } else {\n matchRules = seedMatchRules();\n changes.push('added \"match-rules\" (seeded with the no-fetch guard)');\n }\n\n const rulesDir: string[] = Array.isArray(existing['rulesDir']) ? (existing['rulesDir'] as string[]) : [];\n const config: ConfigFile = { rules, hookGuards, commands, excludePaths, 'match-rules': matchRules, rulesDir };\n if (typeof existing['extends'] === 'string') config.extends = existing['extends'];\n return { config, changes };\n}\n\n// Seed the config when it is missing, migrate it when it is not. ONE behaviour, always — there is no\n// \"migrate but stop here\" mode any more. The flag that used to select it was never NECESSARY (the validator prints\n// the exact edit for every error at once, and editing webpieces.config.json is always allowed through the\n// guard — the documented primary cure), it REFUSED to act when the config was missing (useless in the one\n// case automation would have helped), and it gave deny messages a second competing path when they are\n// supposed to end in exactly one action. Readers also mistook it for the shim-repair command, which it\n// never was — `wp-upgrade-shim` is that.\n// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope\nexport function seedOrSyncConfig(projectRoot: string): void {\n const configPath = path.join(projectRoot, CONFIG_FILENAME);\n if (!fs.existsSync(configPath)) {\n writeConfig(configPath, buildSeedConfig());\n console.log(` [ai-hooks] Created ${CONFIG_FILENAME} (rules / hookGuards / commands); each rule seeded at its recommended mode — gradual where supported, so only code you change is enforced.`);\n console.log(' Enable the ones you want by changing \"mode\".');\n return;\n }\n const result = migrate(readConfig(configPath));\n if (result.changes.length === 0) {\n console.log(` [ai-hooks] ${CONFIG_FILENAME} already uses the rules / hookGuards / commands layout — no changes.`);\n return;\n }\n writeConfig(configPath, result.config);\n console.log(` [ai-hooks] Migrated ${CONFIG_FILENAME}:`);\n for (const change of result.changes) console.log(` - ${change}`);\n}\n"]}
|
package/src/bin/setup.d.ts
DELETED
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import { HarnessRegistration } from './hook-registration';
|
|
2
|
-
import type { ClaudeSettings } from './settings-shape';
|
|
3
|
-
declare class HookSpec {
|
|
4
|
-
readonly key: string;
|
|
5
|
-
readonly label: string;
|
|
6
|
-
readonly bin: string;
|
|
7
|
-
constructor(key: string, label: string, bin: string);
|
|
8
|
-
/**
|
|
9
|
-
* WHICH TOOL NAMES this hook must see, in the harness the target belongs to.
|
|
10
|
-
*
|
|
11
|
-
* It is a lookup on the target rather than a field on the spec because the answer is not a property
|
|
12
|
-
* of the hook: the rules hook matches `Write|Edit|MultiEdit` under Claude Code and `apply_patch`
|
|
13
|
-
* under Codex, and a single stored matcher is exactly how `.codex/hooks.json` came to be registered
|
|
14
|
-
* against tool names Codex never emits.
|
|
15
|
-
*/
|
|
16
|
-
matcherFor(target: InstallTarget): string;
|
|
17
|
-
commandFor(target: InstallTarget, projectRoot: string): string;
|
|
18
|
-
}
|
|
19
|
-
export declare class InstallTarget {
|
|
20
|
-
readonly choice: string;
|
|
21
|
-
readonly label: string;
|
|
22
|
-
readonly settingsPath: string;
|
|
23
|
-
readonly absolute: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* WHICH HARNESS this file arms — it decides the matcher and the shim anchor written into it.
|
|
26
|
-
*
|
|
27
|
-
* REQUIRED, with no default, and the absence of one is the point. A default of
|
|
28
|
-
* CLAUDE_REGISTRATION would make "omit the harness" mean "Claude Code" — a widening that is an
|
|
29
|
-
* ABSENCE rather than a token, so a target built for Codex without it would silently carry
|
|
30
|
-
* `Write|Edit|MultiEdit` and `$CLAUDE_PROJECT_DIR`, which is EXACTLY the silently-unguarded
|
|
31
|
-
* state this class exists to end, and ungreppable besides.
|
|
32
|
-
*/
|
|
33
|
-
readonly harness: HarnessRegistration;
|
|
34
|
-
constructor(choice: string, label: string, settingsPath: string, absolute: boolean,
|
|
35
|
-
/**
|
|
36
|
-
* WHICH HARNESS this file arms — it decides the matcher and the shim anchor written into it.
|
|
37
|
-
*
|
|
38
|
-
* REQUIRED, with no default, and the absence of one is the point. A default of
|
|
39
|
-
* CLAUDE_REGISTRATION would make "omit the harness" mean "Claude Code" — a widening that is an
|
|
40
|
-
* ABSENCE rather than a token, so a target built for Codex without it would silently carry
|
|
41
|
-
* `Write|Edit|MultiEdit` and `$CLAUDE_PROJECT_DIR`, which is EXACTLY the silently-unguarded
|
|
42
|
-
* state this class exists to end, and ungreppable besides.
|
|
43
|
-
*/
|
|
44
|
-
harness: HarnessRegistration);
|
|
45
|
-
}
|
|
46
|
-
export declare const RULES_HOOK: HookSpec;
|
|
47
|
-
export declare const GUARDS_HOOK: HookSpec;
|
|
48
|
-
/**
|
|
49
|
-
* Every file the installer can write, keyed by the CHOICE a human makes.
|
|
50
|
-
*
|
|
51
|
-
* TWO TARGETS SHARE CHOICE `1`, and that is the design rather than an oversight: "the project, committed,
|
|
52
|
-
* for the team" is ONE intention, and a repo that is worked on by both harnesses needs both files armed
|
|
53
|
-
* to mean it. Splitting it into two questions would let a human answer them differently and end up with a
|
|
54
|
-
* repo where Codex is silently unguarded — which is the state this whole change exists to end. Every
|
|
55
|
-
* caller selects by choice id (`targets.filter(t => t.choice === answer)`), never by index, so adding a
|
|
56
|
-
* harness adds a row and changes no numbering.
|
|
57
|
-
*
|
|
58
|
-
* `2` (personal) and `3` (global) stay Claude-only because neither has a Codex counterpart: Codex reads
|
|
59
|
-
* one repo-local `hooks.json` and has no personal or home-scoped hook file.
|
|
60
|
-
*
|
|
61
|
-
* `homeDir` is injectable so tests can point the global target at a temp dir instead of the real
|
|
62
|
-
* ~/.claude/settings.json (a unit test must never write the user's actual global settings).
|
|
63
|
-
*/
|
|
64
|
-
export declare function installTargets(projectRoot: string, homeDir?: string): InstallTarget[];
|
|
65
|
-
export declare function hasHook(settings: ClaudeSettings, bin: string): boolean;
|
|
66
|
-
export declare function applyHook(hook: HookSpec, chosen: InstallTarget | null, targets: InstallTarget[], projectRoot: string): void;
|
|
67
|
-
export declare function resolveTargetChoice(name: string): string | null;
|
|
68
|
-
export declare function parseTargetArg(args: string[]): string | null;
|
|
69
|
-
/**
|
|
70
|
-
* Apply ONE choice for one hook: every target that answer selects, or uninstall when it selects none.
|
|
71
|
-
*
|
|
72
|
-
* The loop is what lets one choice arm several harnesses (choice `1` writes both the Claude settings
|
|
73
|
-
* file and the Codex hooks file — see installTargets). `applyHook` scopes its removals to the chosen
|
|
74
|
-
* target's harness, which is what keeps these calls from undoing one another.
|
|
75
|
-
*/
|
|
76
|
-
export declare function applyChoice(hook: HookSpec, choice: string, targets: InstallTarget[], projectRoot: string): void;
|
|
77
|
-
export declare function main(): Promise<void>;
|
|
78
|
-
export {};
|
package/src/bin/setup.js
DELETED
|
@@ -1,400 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GUARDS_HOOK = exports.RULES_HOOK = exports.InstallTarget = void 0;
|
|
4
|
-
exports.installTargets = installTargets;
|
|
5
|
-
exports.hasHook = hasHook;
|
|
6
|
-
exports.applyHook = applyHook;
|
|
7
|
-
exports.resolveTargetChoice = resolveTargetChoice;
|
|
8
|
-
exports.parseTargetArg = parseTargetArg;
|
|
9
|
-
exports.applyChoice = applyChoice;
|
|
10
|
-
exports.main = main;
|
|
11
|
-
const tslib_1 = require("tslib");
|
|
12
|
-
const fs = tslib_1.__importStar(require("fs"));
|
|
13
|
-
const path = tslib_1.__importStar(require("path"));
|
|
14
|
-
const os_1 = require("os");
|
|
15
|
-
const readline_1 = require("readline");
|
|
16
|
-
const rules_config_1 = require("@webpieces/rules-config");
|
|
17
|
-
const shim_1 = require("./shim");
|
|
18
|
-
const reviewer_agent_1 = require("./reviewer-agent");
|
|
19
|
-
const hook_registration_1 = require("./hook-registration");
|
|
20
|
-
const managed_env_1 = require("./managed-env");
|
|
21
|
-
const codex_trust_1 = require("./codex-trust");
|
|
22
|
-
// The config half of the installer — seeding and migrating webpieces.config.json. Split for size along
|
|
23
|
-
// the seam that was already there: this module is hook WIRING, that one is CONFIG SHAPE.
|
|
24
|
-
const setup_config_1 = require("./setup-config");
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
// The two independently-installable GUARD hooks. Each can land in a different settings file (see
|
|
27
|
-
// InstallTarget) so a team can ship the guards while a developer keeps the code-style rules local
|
|
28
|
-
// while iterating. Both are registered ABSOLUTE via $CLAUDE_PROJECT_DIR, so the MAIN tree governs every
|
|
29
|
-
// tree. There used to be a third — the L-1 hook, which existed only to keep a RELATIVE registration
|
|
30
|
-
// resolvable; it is retired, and purgeRetiredGuaranteeRoot() removes anything left of it.
|
|
31
|
-
// ---------------------------------------------------------------------------
|
|
32
|
-
class HookSpec {
|
|
33
|
-
key;
|
|
34
|
-
label;
|
|
35
|
-
bin;
|
|
36
|
-
constructor(key, label, bin) {
|
|
37
|
-
this.key = key;
|
|
38
|
-
this.label = label;
|
|
39
|
-
this.bin = bin;
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* WHICH TOOL NAMES this hook must see, in the harness the target belongs to.
|
|
43
|
-
*
|
|
44
|
-
* It is a lookup on the target rather than a field on the spec because the answer is not a property
|
|
45
|
-
* of the hook: the rules hook matches `Write|Edit|MultiEdit` under Claude Code and `apply_patch`
|
|
46
|
-
* under Codex, and a single stored matcher is exactly how `.codex/hooks.json` came to be registered
|
|
47
|
-
* against tool names Codex never emits.
|
|
48
|
-
*/
|
|
49
|
-
matcherFor(target) {
|
|
50
|
-
return target.harness.matcherFor(this.bin);
|
|
51
|
-
}
|
|
52
|
-
// Absolute targets (global) need the exact path to this repo's bin — no ~/.webpieces bridge.
|
|
53
|
-
// Project targets get the ABSOLUTE shim command, anchored on the harness's own project-root variable
|
|
54
|
-
// (see HarnessRegistration.shimCommand): it resolves from ANY cwd, so a hook can never fail to
|
|
55
|
-
// launch — which per the hooks reference would be exit 127, a SILENT UNGUARDED ALLOW, not a block.
|
|
56
|
-
commandFor(target, projectRoot) {
|
|
57
|
-
if (target.absolute) {
|
|
58
|
-
return `node ${path.join(projectRoot, 'node_modules', '.bin', this.bin)}`;
|
|
59
|
-
}
|
|
60
|
-
return target.harness.shimCommand(this.bin);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
// Idempotent: re-running the installer overwrites the managed shim in place.
|
|
64
|
-
function writeShim(projectRoot) {
|
|
65
|
-
const target = (0, shim_1.shimPath)(projectRoot);
|
|
66
|
-
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
67
|
-
fs.writeFileSync(target, (0, shim_1.renderShim)(), { mode: 0o755 });
|
|
68
|
-
// writeFileSync's mode is only applied when creating the file; force it on overwrite too.
|
|
69
|
-
fs.chmodSync(target, 0o755);
|
|
70
|
-
}
|
|
71
|
-
function removeShim(projectRoot) {
|
|
72
|
-
const target = (0, shim_1.shimPath)(projectRoot);
|
|
73
|
-
if (fs.existsSync(target))
|
|
74
|
-
fs.rmSync(target);
|
|
75
|
-
}
|
|
76
|
-
// A managed .sh is shared by the project hooks — only safe to delete once no project settings file
|
|
77
|
-
// references it anymore (i.e. the other hook was moved to global or uninstalled too).
|
|
78
|
-
// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
|
|
79
|
-
function markerReferenced(targets, marker) {
|
|
80
|
-
return targets.some((t) => {
|
|
81
|
-
const entries = (0, hook_registration_1.readSettings)(t.settingsPath).hooks?.PreToolUse ?? [];
|
|
82
|
-
return entries.some((e) => e.hooks.some((h) => h.command.includes(marker)));
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* Remove every trace of the RETIRED L-1 hook (`guarantee-root.sh`) — the file and any PreToolUse entry
|
|
87
|
-
* still pointing at it. REMOVAL ONLY: nothing here can ever write one back.
|
|
88
|
-
*
|
|
89
|
-
* L-1 existed to guarantee a RELATIVE guard-hook path resolved, by refusing any `cd` that would park the
|
|
90
|
-
* shell in a subdirectory. The guard hooks are ABSOLUTE now (`$CLAUDE_PROJECT_DIR/...`), so they resolve
|
|
91
|
-
* from any cwd and the guarantee is structural — there is nothing left to police, and the subdirectory
|
|
92
|
-
* denial that used to pay for it is gone with it.
|
|
93
|
-
*/
|
|
94
|
-
// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
|
|
95
|
-
function purgeRetiredGuaranteeRoot(targets, projectRoot) {
|
|
96
|
-
for (const target of targets) {
|
|
97
|
-
const settings = (0, hook_registration_1.readSettings)(target.settingsPath);
|
|
98
|
-
if (removeHookByMarker(settings, hook_registration_1.LEGACY_GUARANTEE_ROOT_MARKER)) {
|
|
99
|
-
(0, hook_registration_1.writeSettings)(target.settingsPath, settings);
|
|
100
|
-
console.log(` 🗑️ removed the retired L-1 guarantee-root hook from ${target.label}`);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
const legacyFile = path.join(projectRoot, hook_registration_1.LEGACY_GUARANTEE_ROOT_MARKER);
|
|
104
|
-
if (fs.existsSync(legacyFile)) {
|
|
105
|
-
fs.rmSync(legacyFile, { force: true });
|
|
106
|
-
console.log(' 🗑️ deleted the retired .claude/webpieces/guarantee-root.sh');
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
class InstallTarget {
|
|
110
|
-
choice;
|
|
111
|
-
label;
|
|
112
|
-
settingsPath;
|
|
113
|
-
absolute;
|
|
114
|
-
harness;
|
|
115
|
-
// eslint-disable-next-line @typescript-eslint/max-params
|
|
116
|
-
constructor(choice, label, settingsPath, absolute,
|
|
117
|
-
/**
|
|
118
|
-
* WHICH HARNESS this file arms — it decides the matcher and the shim anchor written into it.
|
|
119
|
-
*
|
|
120
|
-
* REQUIRED, with no default, and the absence of one is the point. A default of
|
|
121
|
-
* CLAUDE_REGISTRATION would make "omit the harness" mean "Claude Code" — a widening that is an
|
|
122
|
-
* ABSENCE rather than a token, so a target built for Codex without it would silently carry
|
|
123
|
-
* `Write|Edit|MultiEdit` and `$CLAUDE_PROJECT_DIR`, which is EXACTLY the silently-unguarded
|
|
124
|
-
* state this class exists to end, and ungreppable besides.
|
|
125
|
-
*/
|
|
126
|
-
harness) {
|
|
127
|
-
this.choice = choice;
|
|
128
|
-
this.label = label;
|
|
129
|
-
this.settingsPath = settingsPath;
|
|
130
|
-
this.absolute = absolute;
|
|
131
|
-
this.harness = harness;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
exports.InstallTarget = InstallTarget;
|
|
135
|
-
// The bin names come from ./hook-registration, which is also what the drift check and wp-upgrade-shim
|
|
136
|
-
// compare against — one spelling of the registration, or the installer and the validator can disagree
|
|
137
|
-
// about what "installed" means. The MATCHER is not here: it belongs to the harness, not the hook (see
|
|
138
|
-
// HookSpec.matcherFor).
|
|
139
|
-
exports.RULES_HOOK = new HookSpec('rules', 'Rules hook (code-style validation)', hook_registration_1.RULES_BIN);
|
|
140
|
-
exports.GUARDS_HOOK = new HookSpec('guards', 'Guards hook (git/PR/branch protection)', hook_registration_1.GUARDS_BIN);
|
|
141
|
-
/**
|
|
142
|
-
* Every file the installer can write, keyed by the CHOICE a human makes.
|
|
143
|
-
*
|
|
144
|
-
* TWO TARGETS SHARE CHOICE `1`, and that is the design rather than an oversight: "the project, committed,
|
|
145
|
-
* for the team" is ONE intention, and a repo that is worked on by both harnesses needs both files armed
|
|
146
|
-
* to mean it. Splitting it into two questions would let a human answer them differently and end up with a
|
|
147
|
-
* repo where Codex is silently unguarded — which is the state this whole change exists to end. Every
|
|
148
|
-
* caller selects by choice id (`targets.filter(t => t.choice === answer)`), never by index, so adding a
|
|
149
|
-
* harness adds a row and changes no numbering.
|
|
150
|
-
*
|
|
151
|
-
* `2` (personal) and `3` (global) stay Claude-only because neither has a Codex counterpart: Codex reads
|
|
152
|
-
* one repo-local `hooks.json` and has no personal or home-scoped hook file.
|
|
153
|
-
*
|
|
154
|
-
* `homeDir` is injectable so tests can point the global target at a temp dir instead of the real
|
|
155
|
-
* ~/.claude/settings.json (a unit test must never write the user's actual global settings).
|
|
156
|
-
*/
|
|
157
|
-
function installTargets(projectRoot, homeDir = (0, os_1.homedir)()) {
|
|
158
|
-
return [
|
|
159
|
-
new InstallTarget('1', 'project (.claude/settings.json — committed, for the team)', path.join(projectRoot, '.claude', 'settings.json'), false, hook_registration_1.CLAUDE_REGISTRATION),
|
|
160
|
-
new InstallTarget('2', 'project for you (.claude/settings.local.json — personal)', path.join(projectRoot, '.claude', 'settings.local.json'), false, hook_registration_1.CLAUDE_REGISTRATION),
|
|
161
|
-
new InstallTarget('3', 'global (~/.claude/settings.json — exact path, this repo only)', path.join(homeDir, '.claude', 'settings.json'), true, hook_registration_1.CLAUDE_REGISTRATION),
|
|
162
|
-
// Given choice `1` so one answer arms the whole project — see the docblock. Its position in the
|
|
163
|
-
// array carries no meaning: every caller selects by choice id.
|
|
164
|
-
new InstallTarget('1', 'project, for Codex too (.codex/hooks.json — committed, for the team)', path.join(projectRoot, ...hook_registration_1.CODEX_REGISTRATION.settingsFiles[0].split('/')), false, hook_registration_1.CODEX_REGISTRATION),
|
|
165
|
-
];
|
|
166
|
-
}
|
|
167
|
-
// ---------------------------------------------------------------------------
|
|
168
|
-
// Claude Code settings.json hook wiring.
|
|
169
|
-
// ---------------------------------------------------------------------------
|
|
170
|
-
function hasHook(settings, bin) {
|
|
171
|
-
const entries = settings.hooks?.PreToolUse ?? [];
|
|
172
|
-
return entries.some((e) => e.hooks.some((h) => h.command.includes(bin)));
|
|
173
|
-
}
|
|
174
|
-
// Drop every PreToolUse command containing `marker` (a bin name, or a managed .sh path); returns true
|
|
175
|
-
// if anything was removed. REMOVE-then-ADD is what keeps an upgrade from leaving a superseded spelling
|
|
176
|
-
// (a relative command, or the retired L-1 entry) beside the current one — two spellings of one
|
|
177
|
-
// registration is the compatibility shim the backwards-compat reviewer rejects.
|
|
178
|
-
// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
|
|
179
|
-
function removeHookByMarker(settings, marker) {
|
|
180
|
-
const entries = settings.hooks?.PreToolUse;
|
|
181
|
-
if (!entries)
|
|
182
|
-
return false;
|
|
183
|
-
let changed = false;
|
|
184
|
-
const kept = [];
|
|
185
|
-
for (const entry of entries) {
|
|
186
|
-
const hooks = entry.hooks.filter((h) => !h.command.includes(marker));
|
|
187
|
-
if (hooks.length !== entry.hooks.length)
|
|
188
|
-
changed = true;
|
|
189
|
-
if (hooks.length > 0)
|
|
190
|
-
kept.push({ matcher: entry.matcher, hooks });
|
|
191
|
-
}
|
|
192
|
-
if (changed)
|
|
193
|
-
settings.hooks.PreToolUse = kept;
|
|
194
|
-
return changed;
|
|
195
|
-
}
|
|
196
|
-
// Apply the chosen install for one hook: remove it from every target file, then add it back to the
|
|
197
|
-
// chosen one (or nowhere, for uninstall). Writes only the files that changed.
|
|
198
|
-
function applyHook(hook, chosen, targets, projectRoot) {
|
|
199
|
-
// SCOPED TO THE CHOSEN HARNESS, and this is what makes one call per target composable. Installing
|
|
200
|
-
// the Claude hook must not strip the Codex one, so "remove it from everywhere else" means everywhere
|
|
201
|
-
// else THIS HARNESS could live. Uninstall (chosen === null) is the one case that means every
|
|
202
|
-
// harness, because "not installed" has to be true everywhere or the hook is still armed somewhere.
|
|
203
|
-
const scope = chosen === null ? targets : targets.filter((t) => t.harness === chosen.harness);
|
|
204
|
-
for (const target of scope) {
|
|
205
|
-
const settings = (0, hook_registration_1.readSettings)(target.settingsPath);
|
|
206
|
-
const removed = removeHookByMarker(settings, hook.bin);
|
|
207
|
-
const isChosen = chosen !== null && chosen.settingsPath === target.settingsPath;
|
|
208
|
-
if (isChosen) {
|
|
209
|
-
(0, hook_registration_1.addHookEntry)(settings, new hook_registration_1.HookRegistrationEntry(hook.matcherFor(target), hook.commandFor(target, projectRoot)));
|
|
210
|
-
// The managed `env` entry goes into the SAME file the hooks go into, on every path that
|
|
211
|
-
// writes hooks — interactive or `--target=`. It pins the Bash cwd to the project root, so a
|
|
212
|
-
// guard's answer depends on the command rather than on where an earlier `cd` left the shell,
|
|
213
|
-
// and settings `env` is inherited, so every subagent gets the identical cwd and therefore the
|
|
214
|
-
// identical guard verdict. (It no longer has a RESOLUTION job — the hooks are absolute.) See
|
|
215
|
-
// hook-registration.ts for the full argument; `wp-upgrade-shim` self-heals it afterwards.
|
|
216
|
-
// …in the harness that HAS that surface. Codex has no settings `env`, and needs none: its
|
|
217
|
-
// cwd is MEASURED not to drift, which is the whole thing this entry buys under Claude Code.
|
|
218
|
-
if (target.harness.managesEnv && (0, hook_registration_1.applyManagedEnv)(settings)) {
|
|
219
|
-
console.log(` ✅ env.${managed_env_1.BASH_CWD_ENV_KEY}=${managed_env_1.BASH_CWD_ENV_VALUE} → ${target.label} (pins the Bash cwd to the project root, for this session and every subagent)`);
|
|
220
|
-
}
|
|
221
|
-
(0, hook_registration_1.writeSettings)(target.settingsPath, settings);
|
|
222
|
-
console.log(` ✅ ${hook.label} → ${target.label}`);
|
|
223
|
-
}
|
|
224
|
-
else if (removed) {
|
|
225
|
-
(0, hook_registration_1.writeSettings)(target.settingsPath, settings);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
// Manage the shared checked-in shim: (re)write it whenever a project (relative) install exists,
|
|
229
|
-
// otherwise clean it up once neither hook references it anymore.
|
|
230
|
-
if (chosen !== null && !chosen.absolute) {
|
|
231
|
-
writeShim(projectRoot);
|
|
232
|
-
// The generic PR-gate reviewer agent is part of the same committed, managed set as the shim — the
|
|
233
|
-
// drift check reports it beside the shim, so the installer writes it beside the shim.
|
|
234
|
-
if ((0, reviewer_agent_1.writeReviewerAgent)(projectRoot)) {
|
|
235
|
-
console.log(` ✅ ${reviewer_agent_1.REVIEWER_AGENT_MARKER} (the generic PR-gate reviewer; generated — commit it, do not edit it)`);
|
|
236
|
-
}
|
|
237
|
-
}
|
|
238
|
-
else if (!markerReferenced(targets, shim_1.SHIM_MARKER)) {
|
|
239
|
-
removeShim(projectRoot);
|
|
240
|
-
}
|
|
241
|
-
// The RETIRED L-1 hook rode with the GUARDS hook, so its removal does too. Doing it here rather than
|
|
242
|
-
// at a separate call site means every existing caller of applyHook — the installer's interactive and
|
|
243
|
-
// --target paths, and every test — converges on the two-hook absolute form with no second step.
|
|
244
|
-
if (hook.bin === hook_registration_1.GUARDS_BIN)
|
|
245
|
-
purgeRetiredGuaranteeRoot(targets, projectRoot);
|
|
246
|
-
if (chosen === null)
|
|
247
|
-
console.log(` ⛔ ${hook.label} not installed (removed from all locations).`);
|
|
248
|
-
}
|
|
249
|
-
/**
|
|
250
|
-
* Say whether Codex will actually RUN what we just registered — the one thing the installer cannot do
|
|
251
|
-
* anything about and therefore must not leave silent.
|
|
252
|
-
*
|
|
253
|
-
* Codex trusts a hook entry TOFU and re-prompts whenever its bytes change, and the prompt's third option
|
|
254
|
-
* is "Continue without trusting (hooks won't run)". So a perfectly successful install can be followed by
|
|
255
|
-
* a fully unguarded session, and the only honest thing to print is what is true plus the one action a
|
|
256
|
-
* HUMAN has to take. Nothing here writes `~/.codex/config.toml` — see codex-trust.ts for why forging a
|
|
257
|
-
* `trusted_hash` is not on the table.
|
|
258
|
-
*
|
|
259
|
-
* Silent when this repo did not arm Codex, so a Claude-only install gains no noise.
|
|
260
|
-
*/
|
|
261
|
-
// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
|
|
262
|
-
function reportCodexTrust(projectRoot, targets, choice) {
|
|
263
|
-
const armed = targets.some((t) => t.choice === choice && t.harness === hook_registration_1.CODEX_REGISTRATION);
|
|
264
|
-
if (!armed)
|
|
265
|
-
return;
|
|
266
|
-
const lines = new codex_trust_1.CodexTrustProbe().read(projectRoot).lines();
|
|
267
|
-
if (lines.length === 0)
|
|
268
|
-
return;
|
|
269
|
-
console.log('');
|
|
270
|
-
for (const line of lines)
|
|
271
|
-
console.log(line);
|
|
272
|
-
}
|
|
273
|
-
function currentLocation(hook, targets) {
|
|
274
|
-
const here = targets.filter((t) => hasHook((0, hook_registration_1.readSettings)(t.settingsPath), hook.bin));
|
|
275
|
-
return here.length === 0 ? 'none' : here.map((t) => t.label.split(' (')[0]).join(', ');
|
|
276
|
-
}
|
|
277
|
-
function prompt(question) {
|
|
278
|
-
return new Promise((resolve) => {
|
|
279
|
-
const rl = (0, readline_1.createInterface)({ input: process.stdin, output: process.stdout });
|
|
280
|
-
rl.question(question, (answer) => { rl.close(); resolve(answer.trim()); });
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
// Map a friendly `--target` name to an InstallTarget choice id (see installTargets). Returns null
|
|
284
|
-
// for an unknown name so the caller can error out. Kept separate + exported for unit testing.
|
|
285
|
-
function resolveTargetChoice(name) {
|
|
286
|
-
switch (name) {
|
|
287
|
-
case 'project': return '1';
|
|
288
|
-
case 'project-personal':
|
|
289
|
-
case 'projectpersonal':
|
|
290
|
-
case 'local': return '2';
|
|
291
|
-
case 'global': return '3';
|
|
292
|
-
case 'none':
|
|
293
|
-
case 'uninstall': return '4';
|
|
294
|
-
default: return null;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
// Extract the value of `--target=<name>` from argv (null if the flag is absent).
|
|
298
|
-
function parseTargetArg(args) {
|
|
299
|
-
const flag = args.find((a) => a.startsWith('--target='));
|
|
300
|
-
return flag ? flag.slice('--target='.length) : null;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Apply ONE choice for one hook: every target that answer selects, or uninstall when it selects none.
|
|
304
|
-
*
|
|
305
|
-
* The loop is what lets one choice arm several harnesses (choice `1` writes both the Claude settings
|
|
306
|
-
* file and the Codex hooks file — see installTargets). `applyHook` scopes its removals to the chosen
|
|
307
|
-
* target's harness, which is what keeps these calls from undoing one another.
|
|
308
|
-
*/
|
|
309
|
-
// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
|
|
310
|
-
function applyChoice(hook, choice, targets, projectRoot) {
|
|
311
|
-
const chosen = targets.filter((t) => t.choice === choice);
|
|
312
|
-
if (chosen.length === 0) {
|
|
313
|
-
applyHook(hook, null, targets, projectRoot);
|
|
314
|
-
return;
|
|
315
|
-
}
|
|
316
|
-
for (const target of chosen)
|
|
317
|
-
applyHook(hook, target, targets, projectRoot);
|
|
318
|
-
}
|
|
319
|
-
async function wireHook(hook, targets, projectRoot) {
|
|
320
|
-
console.log('');
|
|
321
|
-
console.log(`${hook.label}`);
|
|
322
|
-
console.log(` currently installed in: ${currentLocation(hook, targets)}`);
|
|
323
|
-
// The matcher is printed PER TARGET now, because it differs per harness — Codex's file tool is
|
|
324
|
-
// `apply_patch`, Claude's are Write|Edit|MultiEdit — and one matcher printed above the list would be
|
|
325
|
-
// wrong for whichever harness it did not describe.
|
|
326
|
-
for (const target of targets)
|
|
327
|
-
console.log(` ${target.choice}) ${target.label} [matcher: ${hook.matcherFor(target)}]`);
|
|
328
|
-
console.log(' 4) none / uninstall');
|
|
329
|
-
const answer = await prompt(' Where should it live? [1/2/3/4, default 4]: ');
|
|
330
|
-
applyChoice(hook, answer, targets, projectRoot);
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Scaffold the SERVER-SIDE PR gate: the CI workflow plus the doc explaining how to turn it on.
|
|
334
|
-
*
|
|
335
|
-
* This lives in the installer, not the PR flow. `wp-start-upsert-pr` used to do it — printing
|
|
336
|
-
* copy-to-`.github` and branch-protection instructions on EVERY run, at an agent doing feature work
|
|
337
|
-
* that could not act on them anyway (marking a check required needs a repo admin). Setup is a
|
|
338
|
-
* one-time, admin-shaped act, so it belongs with the other one-time setup.
|
|
339
|
-
*
|
|
340
|
-
* Written UNCONDITIONALLY, unlike the old version which required a `gateSalt` to already be set: the
|
|
341
|
-
* whole point of the doc is to tell you to set one, so gating it on the thing it teaches meant the
|
|
342
|
-
* instructions only appeared to repos that no longer needed them.
|
|
343
|
-
*
|
|
344
|
-
* Both land in gitignored `.webpieces/instruct-ai/`, never `.github/` directly — writing there would
|
|
345
|
-
* dirty the tree, and copying it is the human's decision. `IfMissing` for the yml so a repo that has
|
|
346
|
-
* customized its workflow never gets it clobbered; the doc itself is refreshed so it cannot go stale.
|
|
347
|
-
*/
|
|
348
|
-
// webpieces-disable no-function-outside-class -- setup.ts is deliberately DI-free (it must run on a half-written node_modules; see install-entry.ts), so every function here is module-scope
|
|
349
|
-
function scaffoldCiGate(projectRoot) {
|
|
350
|
-
(0, rules_config_1.writeTemplateIfMissing)(projectRoot, 'webpieces-pr-gate.yml');
|
|
351
|
-
(0, rules_config_1.writeTemplate)(projectRoot, 'webpieces.ci-gate-setup.md');
|
|
352
|
-
console.log('');
|
|
353
|
-
console.log('ℹ️ Optional: server-side PR gate (stops an UNHOOKED teammate opening a PR in the web UI).');
|
|
354
|
-
console.log(' It is OFF until you set a gateSalt. Three steps, one of which needs a repo admin:');
|
|
355
|
-
console.log(' .webpieces/instruct-ai/webpieces.ci-gate-setup.md');
|
|
356
|
-
}
|
|
357
|
-
async function main() {
|
|
358
|
-
const args = process.argv.slice(2);
|
|
359
|
-
// Anchor the install at the repo root (git toplevel — webpieces.config.json may not exist yet on
|
|
360
|
-
// a first install), never a subdir cwd, so `.webpieces`/hooks/config all land at the root.
|
|
361
|
-
const projectRoot = new rules_config_1.RepoRootFinder().resolveRepoRoot(process.cwd());
|
|
362
|
-
(0, setup_config_1.seedOrSyncConfig)(projectRoot);
|
|
363
|
-
// Always refreshed: it explains why a retired key is rejected rather than accepted, and what to do
|
|
364
|
-
// about it — which is exactly what an agent needs on the run where a migration just moved keys out
|
|
365
|
-
// from under its config.
|
|
366
|
-
(0, rules_config_1.writeTemplate)(projectRoot, rules_config_1.CONFIG_POLICY_DOC);
|
|
367
|
-
scaffoldCiGate(projectRoot);
|
|
368
|
-
const targets = installTargets(projectRoot);
|
|
369
|
-
// Non-interactive: `--target=project|project-personal|global|none` installs BOTH hooks at that
|
|
370
|
-
// location without prompting, so an agent or CI can run the installer unattended (e.g. after a
|
|
371
|
-
// @webpieces upgrade that changed the hook entry). Omit the flag for the interactive per-hook chooser.
|
|
372
|
-
const targetName = parseTargetArg(args);
|
|
373
|
-
if (targetName !== null) {
|
|
374
|
-
const choice = resolveTargetChoice(targetName);
|
|
375
|
-
if (choice === null) {
|
|
376
|
-
console.error(`❌ Unknown --target '${targetName}'. Use one of: project | project-personal | global | none`);
|
|
377
|
-
process.exitCode = 1;
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
applyChoice(exports.RULES_HOOK, choice, targets, projectRoot);
|
|
381
|
-
applyChoice(exports.GUARDS_HOOK, choice, targets, projectRoot);
|
|
382
|
-
console.log(`\nDone. Both hooks set to: ${targetName}.`);
|
|
383
|
-
reportCodexTrust(projectRoot, targets, choice);
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
console.log('');
|
|
387
|
-
console.log('Two webpieces hooks can be installed independently — choose a location for each:');
|
|
388
|
-
await wireHook(exports.RULES_HOOK, targets, projectRoot);
|
|
389
|
-
await wireHook(exports.GUARDS_HOOK, targets, projectRoot);
|
|
390
|
-
// Whichever choices were made above, report Codex trust for the project choice — an interactive run
|
|
391
|
-
// that armed Codex needs the same warning the --target path prints.
|
|
392
|
-
reportCodexTrust(projectRoot, targets, '1');
|
|
393
|
-
console.log('');
|
|
394
|
-
console.log('Done. Re-run `pnpm wp-install-ai-hooks` anytime to move or uninstall a hook.');
|
|
395
|
-
console.log('(Non-interactive: pnpm wp-install-ai-hooks --target=project|project-personal|global|none)');
|
|
396
|
-
}
|
|
397
|
-
if (require.main === module) {
|
|
398
|
-
void main();
|
|
399
|
-
}
|
|
400
|
-
//# sourceMappingURL=setup.js.map
|