@webpieces/ai-hook-rules 0.4.550 → 0.4.552
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/package.json +2 -2
- package/src/bin/l0-allowlist.d.ts +9 -1
- package/src/bin/l0-allowlist.js +28 -7
- package/src/bin/l0-allowlist.js.map +1 -1
- package/src/bin/setup.js +13 -12
- package/src/bin/setup.js.map +1 -1
- package/src/bin/shim.js +17 -4
- package/src/bin/shim.js.map +1 -1
- package/src/core/l0-matrix.d.ts +23 -1
- package/src/core/l0-matrix.js +108 -14
- package/src/core/l0-matrix.js.map +1 -1
- package/templates/ai-hook.sh +14 -2
package/templates/ai-hook.sh
CHANGED
|
@@ -134,7 +134,7 @@ case "$FILE" in
|
|
|
134
134
|
wp_log ALLOW-CONFIG # the always-allowed recovery target — every guard is configured from it
|
|
135
135
|
exit 0 ;;
|
|
136
136
|
esac
|
|
137
|
-
if printf '%s' "$CMD" | grep -Eq '^(cd[[:space:]]+[A-Za-z0-9._/@~+-]+[[:space:]]*&&[[:space:]]*)?((pnpm|npm)[[:space:]]+(install|i)([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*|rm[[:space:]]+-rf[[:space:]]+(\./)?node_modules/?([[:space:]]*&&[[:space:]]*(pnpm|npm)[[:space:]]+(install|i)([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*)?|git[[:space:]]+(pull|fetch)([[:space:]]+(--)?[A-Za-z0-9][A-Za-z0-9=._/@:-]*)*|(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-upgrade-shim|cp[[:space:]]+(\./)?node_modules/@webpieces/ai-hook-rules/templates/ai-hook\.sh[[:space:]]+(\./)?\.claude/webpieces/ai-hook\.sh|(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-install-ai-hooks)([[:space:]]+2>(&1|/dev/null))?([[:space:]]*\|[[:space:]]*(tail|head)([[:space:]]+-(n[[:space:]]+)?[0-9]+)?)?[[:space:]]*$'; then
|
|
137
|
+
if printf '%s' "$CMD" | grep -Eq '^(cd[[:space:]]+[A-Za-z0-9._/@~+-]+[[:space:]]*&&[[:space:]]*)?((pnpm|npm)[[:space:]]+(install|i)([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*|rm[[:space:]]+-rf[[:space:]]+(\./)?node_modules/?([[:space:]]*&&[[:space:]]*(pnpm|npm)[[:space:]]+(install|i)([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*)?|git[[:space:]]+(pull|fetch)([[:space:]]+(--)?[A-Za-z0-9][A-Za-z0-9=._/@:-]*)*|(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-upgrade-shim|cp[[:space:]]+(\./)?node_modules/@webpieces/ai-hook-rules/templates/ai-hook\.sh[[:space:]]+(\./)?\.claude/webpieces/ai-hook\.sh|(pnpm|npm|npx)([[:space:]]+(exec|run))?[[:space:]]+wp-install-ai-hooks([[:space:]]+--[A-Za-z][A-Za-z0-9=._/@:-]*)*)([[:space:]]+2>(&1|/dev/null))?([[:space:]]*\|[[:space:]]*(tail|head)([[:space:]]+-(n[[:space:]]+)?[0-9]+)?)?[[:space:]]*$'; then
|
|
138
138
|
wp_log ALLOW-CURE # record the self-heal we let through (re-enables the guards)
|
|
139
139
|
exit 0 # allow the cure so the assistant can break the deadlock
|
|
140
140
|
fi
|
|
@@ -161,7 +161,19 @@ elif [ -n "$DRIFT_PKG" ]; then
|
|
|
161
161
|
# check is a plain !=, so it fires BOTH ways, and the old text always claimed node_modules was the
|
|
162
162
|
# older side. When it is actually the NEWER side (a checkout behind origin), that text sent people
|
|
163
163
|
# to 'pnpm install', which DOWNGRADES them further from correct.
|
|
164
|
-
|
|
164
|
+
#
|
|
165
|
+
# But "which side is stale" is NOT the same question as "what clears the block". 'pnpm install' clears
|
|
166
|
+
# fault D in BOTH directions by definition — it makes installed == pin. The old text never said so, so
|
|
167
|
+
# a reader on the OPTION 2 branch could not tell whether it was even permitted to install. The only
|
|
168
|
+
# real question is whether the PIN is the version you WANT, and that has three legitimate answers,
|
|
169
|
+
# including deliberately staying on the older code (a checkout + feature branch + install to
|
|
170
|
+
# downgrade). Saying that out loud stops it being improvised as a reset --hard.
|
|
171
|
+
#
|
|
172
|
+
# The FEATURE-BRANCH case is why featureBranchSyncAdvice() is a separate method: wp-start-update is
|
|
173
|
+
# NOT on the L0 allowlist (a 3-point merge is not a tooling-integrity cure), so it can only be offered
|
|
174
|
+
# AFTER the install that clears this block and re-arms the guards. Prescribing it while the block is
|
|
175
|
+
# up would be the same deny-names-a-denied-command deadlock this module exists to prevent.
|
|
176
|
+
REASON="❌ webpieces version drift: package.json pins $DRIFT_PKG@$DRIFT_DECLARED but node_modules has $DRIFT_INSTALLED. Every OTHER call is blocked until they agree. 'pnpm install' ALWAYS clears this block, in BOTH directions - it makes node_modules match the pin by definition, and it is allowed through while this guard is up. The only question is whether the PIN is the version you WANT, so compare the two versions above. OPTION 1 (node_modules is OLDER than the pin - you just pulled or switched to a branch pinning a newer webpieces) - run EXACTLY this command and you are done: 'pnpm install'. OPTION 2 (node_modules is NEWER than the pin - your checkout is behind origin, so the PIN is the stale side, and a bare 'pnpm install' would DOWNGRADE you) - if you are ON MAIN, get the checkout current FIRST and then install: run 'git pull origin main', and after it succeeds run 'pnpm install'. OPTION 3 (node_modules is NEWER than the pin and you deliberately want to stay on the OLD code) - check out the exact commit you want, create a feature branch from it, then run 'pnpm install' to bring node_modules DOWN to the version that commit pinned. That is a legitimate choice, not a mistake - the downgrade is the point. ON A FEATURE BRANCH: a bare 'pnpm install' aligns node_modules to YOUR BRANCH pin, which is usually what you want, and it clears this block. If you actually want main's newer @webpieces, still run 'pnpm install' FIRST to clear the drift and re-arm the guards, and only THEN sync from main normally. To sync a FEATURE branch from main use pnpm wp-start-update (no PR open) or pnpm wp-start-upsert-pr (a PR is open). Do NOT try to run those two while this block is up: they are not on the allowlist, and they do not need to be - the install comes first. To get main itself current: ON main, run 'git pull origin main'. In a linked worktree (main is checked out in the primary clone, so checkout main fatals there), run 'git fetch origin main' and branch off origin/main. Do NOT reach for git merge --ff-only / git reset --hard / git checkout -B main: merge and rebase are blocked in EVERY form by redirect-how-to-merge-main, and the reset/-B forms silently throw away commits. git pull and git fetch are allowed while this guard is up and are the cure here. git merge is NOT allowed - not by this guard and not by redirect-how-to-merge-main once the guards are back - because main is merged ONLY through the 3-point fork merge: 'pnpm wp-start-update', or 'pnpm wp-start-upsert-pr' when a PR is already open. Type the option you pick EXACTLY as written, character for character, and run NOTHING else on that line. Seriously: do NOT append && anything (not even a harmless && git status), do NOT wrap it in a subshell. The allowlist is anchored to the ENTIRE command, so anything you bolt on makes it a DIFFERENT command and it WILL be rejected again - which is not the guard refusing its own cure. If an option already contains &&, that && is part of the command: keep it, and still add nothing beyond it. The only additions tolerated are a LEADING cd <dir> && (needed to run the cure in a linked worktree, since the harness resets a cwd that left the workspace and puts you back in the primary clone - that one IS accepted), a trailing 2>&1, and a pipe into tail/head (e.g. cd /path/to/worktree && pnpm install 2>&1 | tail -20)."
|
|
165
177
|
else
|
|
166
178
|
# A LINKED WORKTREE is the overwhelmingly common way to land here with a perfectly healthy repo:
|
|
167
179
|
# git gives the new worktree a .git FILE (the primary clone has a .git directory) and copies no
|