@bookedsolid/rea 0.16.1 → 0.16.2

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/.husky/commit-msg CHANGED
@@ -99,9 +99,15 @@ if grep -qiE '^\s*(Generated|Created|Built|Powered|Authored|Written|Produced)\s+
99
99
  fi
100
100
 
101
101
  # Pattern 4: Markdown-linked attribution
102
- if grep -qiE '\[Claude Code\]|\[GitHub Copilot\]|\[ChatGPT\]|\[Gemini\]|\[Cursor\]' "$COMMIT_MSG_FILE" 2>/dev/null; then
102
+ # 0.16.2 helix-017 P3 #4: anchor on the markdown link shape `[Text](url)`
103
+ # rather than bare `[Text]`. Pre-fix the regex matched ANY bracketed
104
+ # mention — `feat: support [Claude Code] hook output format` would block
105
+ # a perfectly legitimate commit. The markdown-link form requires the `(`
106
+ # immediately after the closing bracket, which is the actual structural
107
+ # attribution we want to catch.
108
+ if grep -qiE '\[Claude Code\]\(|\[GitHub Copilot\]\(|\[ChatGPT\]\(|\[Gemini\]\(|\[Cursor\]\(' "$COMMIT_MSG_FILE" 2>/dev/null; then
103
109
  BLOCKED=1
104
- MATCHES="${MATCHES}$(grep -niE '\[Claude Code\]|\[GitHub Copilot\]|\[ChatGPT\]|\[Gemini\]|\[Cursor\]' "$COMMIT_MSG_FILE" 2>/dev/null)
110
+ MATCHES="${MATCHES}$(grep -niE '\[Claude Code\]\(|\[GitHub Copilot\]\(|\[ChatGPT\]\(|\[Gemini\]\(|\[Cursor\]\(' "$COMMIT_MSG_FILE" 2>/dev/null)
105
111
  "
106
112
  fi
107
113
 
@@ -183,6 +183,34 @@ any_segment_raw_matches() {
183
183
  return 1
184
184
  }
185
185
 
186
+ # Return 0 if any single segment of $1 (after prefix-stripping) matches
187
+ # BOTH extended regex $2 AND extended regex $3. Case-insensitive. Returns
188
+ # 1 if no single segment matches both patterns.
189
+ #
190
+ # Use this when two patterns must co-occur within the SAME shell command
191
+ # segment to constitute a detection — e.g. env-file-protection's
192
+ # "utility + .env-filename" rule. Pre-fix env-file-protection used two
193
+ # independent `any_segment_matches` calls and OR-combined the booleans,
194
+ # which mis-fires across multi-segment constructions like
195
+ # `echo "log: cat is broken" ; touch foo.env` (utility in segment 1,
196
+ # .env name in segment 2 — both flags set, false-positive block).
197
+ #
198
+ # 0.16.2 helix-017 P2 #2 fix.
199
+ any_segment_matches_both() {
200
+ local cmd="$1"
201
+ local pattern_a="$2"
202
+ local pattern_b="$3"
203
+ local segment stripped
204
+ while IFS= read -r segment; do
205
+ stripped=$(_rea_strip_prefix "$segment")
206
+ if printf '%s' "$stripped" | grep -qiE "$pattern_a" \
207
+ && printf '%s' "$stripped" | grep -qiE "$pattern_b"; then
208
+ return 0
209
+ fi
210
+ done < <(_rea_split_segments "$cmd")
211
+ return 1
212
+ }
213
+
186
214
  # Return 0 if any segment of $1 (after prefix-stripping) STARTS WITH
187
215
  # the extended regex $2. Case-insensitive. Returns 1 if no segment
188
216
  # starts with the pattern.
@@ -92,7 +92,11 @@ if any_segment_matches "$CMD" '(Generated|Created|Built|Powered|Authored|Written
92
92
  fi
93
93
 
94
94
  # Markdown-linked attribution
95
- if any_segment_matches "$CMD" '\[Claude Code\]|\[GitHub Copilot\]|\[ChatGPT\]|\[Gemini\]|\[Cursor\]'; then
95
+ # 0.16.2 helix-017 P3 #4: anchor on `[Text](` (markdown link shape) so
96
+ # legitimate bracketed mentions like `gh pr edit --body "support [Claude
97
+ # Code] hook output"` don't false-positive. The actual attribution we
98
+ # care about is structural — `Generated with [Claude Code](https://...)`.
99
+ if any_segment_matches "$CMD" '\[Claude Code\]\(|\[GitHub Copilot\]\(|\[ChatGPT\]\(|\[Gemini\]\(|\[Cursor\]\('; then
96
100
  FOUND=1
97
101
  fi
98
102
 
@@ -71,19 +71,16 @@ PATTERN_CP_ENV='cp[[:space:]]+[^;|&]*\.env'
71
71
  # .env* files or .envrc (direnv)
72
72
  PATTERN_ENV_FILE='(\.env[a-zA-Z0-9._-]*|\.envrc)([[:space:]]|"|'"'"'|$)'
73
73
 
74
- MATCHES_UTILITY=0
75
- MATCHES_ENV_FILE=0
76
-
77
- # 0.15.0: per-segment match. Pre-fix this greped the FULL command which
78
- # false-positived on commit messages: `git commit -m "stop reading .env
79
- # files via cat"` matched both PATTERN_UTILITY (cat) and PATTERN_ENV_FILE
80
- # (.env) and the hook blocked a perfectly safe commit.
81
- if any_segment_matches "$CMD" "$PATTERN_UTILITY"; then
82
- MATCHES_UTILITY=1
83
- fi
84
-
85
- if any_segment_matches "$CMD" "$PATTERN_ENV_FILE"; then
86
- MATCHES_ENV_FILE=1
74
+ # 0.16.2 helix-017 P2 #2: utility AND env-filename must co-occur within
75
+ # the SAME shell segment. Pre-fix this set two independent booleans
76
+ # (any segment with utility OR any segment with .env) and AND'd them,
77
+ # which false-positived across multi-segment constructions like
78
+ # `echo "log: cat is broken" ; touch foo.env` (utility in segment 1,
79
+ # .env name in segment 2). Detection is fundamentally a same-segment
80
+ # co-occurrence property.
81
+ MATCHES_BOTH_SAME_SEGMENT=0
82
+ if any_segment_matches_both "$CMD" "$PATTERN_UTILITY" "$PATTERN_ENV_FILE"; then
83
+ MATCHES_BOTH_SAME_SEGMENT=1
87
84
  fi
88
85
 
89
86
  # Direct source/cp of .env files — always block
@@ -101,7 +98,7 @@ if any_segment_matches "$CMD" "$PATTERN_SOURCE" || \
101
98
  exit 2
102
99
  fi
103
100
 
104
- if [[ $MATCHES_UTILITY -eq 1 && $MATCHES_ENV_FILE -eq 1 ]]; then
101
+ if [[ $MATCHES_BOTH_SAME_SEGMENT -eq 1 ]]; then
105
102
  TRUNCATED_CMD=$(truncate_cmd "$CMD")
106
103
  {
107
104
  printf 'ENV FILE PROTECTION: Reading .env files via Bash is blocked.\n'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bookedsolid/rea",
3
- "version": "0.16.1",
3
+ "version": "0.16.2",
4
4
  "description": "Agentic governance layer for Claude Code — policy enforcement, hook-based safety gates, audit logging, and Codex-integrated adversarial review for AI-assisted projects",
5
5
  "license": "MIT",
6
6
  "author": "Booked Solid Technology <oss@bookedsolid.tech> (https://bookedsolid.tech)",