rhachet-roles-ehmpathy 1.12.0 → 1.12.1

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.
@@ -112,8 +112,27 @@ match_pattern() {
112
112
  local cmd="$1"
113
113
  local pattern="$2"
114
114
 
115
- # Convert glob * to regex .*
116
- local regex="^${pattern//\*/.*}$"
115
+ # Handle Claude Code's :* suffix matcher
116
+ # :* means "optionally match colon and anything after"
117
+ # e.g., "npm run test:*" matches "npm run test", "npm run test:", "npm run test:unit"
118
+
119
+ # First, escape regex special chars except * and :
120
+ local escaped_pattern
121
+ escaped_pattern=$(printf '%s' "$pattern" | sed 's/[.^$+?{}()[\]|\\]/\\&/g')
122
+
123
+ # Convert :* to placeholder first (to avoid * -> .* conversion interfering)
124
+ # Using a unique placeholder that won't appear in commands
125
+ escaped_pattern="${escaped_pattern//:\*/__COLON_STAR_PLACEHOLDER__}"
126
+
127
+ # Convert remaining * to .* (glob-style wildcard)
128
+ escaped_pattern="${escaped_pattern//\*/.*}"
129
+
130
+ # Now replace placeholder with the actual regex for :*
131
+ # (:.*)? matches: nothing, ":", ":foo", ":foo:bar"
132
+ escaped_pattern="${escaped_pattern//__COLON_STAR_PLACEHOLDER__/(:.*)?}"
133
+
134
+ # Build final regex
135
+ local regex="^${escaped_pattern}$"
117
136
 
118
137
  if [[ "$cmd" =~ $regex ]]; then
119
138
  return 0
@@ -121,6 +140,21 @@ match_pattern() {
121
140
  return 1
122
141
  }
123
142
 
143
+ # Transform raw permission pattern to compact bracket notation for display
144
+ format_pattern() {
145
+ local pattern="$1"
146
+
147
+ # Check if pattern ends with :*
148
+ if [[ "$pattern" == *":*" ]]; then
149
+ # Remove :* suffix and format with [p]: label (prefix match)
150
+ local prefix="${pattern%:*}"
151
+ echo "[p]: $prefix"
152
+ else
153
+ # Exact match - format with [e]: label
154
+ echo "[e]: $pattern"
155
+ fi
156
+ }
157
+
124
158
  for pattern in "${ALLOWED_PATTERNS[@]}"; do
125
159
  if match_pattern "$COMMAND" "$pattern"; then
126
160
  exit 0 # Command matches an allowed pattern
@@ -137,10 +171,14 @@ if [[ "$MODE" == "SOFTNUDGE" ]]; then
137
171
  echo ""
138
172
  echo "Before requesting user approval, check if you can accomplish this task using one of these pre-approved patterns:"
139
173
  echo ""
174
+ echo "([e] = exact match, [p] = prefix match)"
175
+ echo ""
140
176
  for pattern in "${ALLOWED_PATTERNS[@]}"; do
141
- echo " • $pattern"
177
+ echo " • $(format_pattern "$pattern")"
142
178
  done
143
179
  echo ""
180
+ echo "([e] = exact match, [p] = prefix match)"
181
+ echo ""
144
182
  echo "If an existing permission pattern can solve your task, use that instead."
145
183
  echo "If not, proceed with requesting approval."
146
184
  echo ""
@@ -182,10 +220,14 @@ jq --arg cmd "$COMMAND" --argjson ts "$now" '. + {($cmd): $ts}' "$ATTEMPTED_FILE
182
220
  echo ""
183
221
  echo "Before requesting user approval, check if you can accomplish this task using one of these pre-approved patterns:"
184
222
  echo ""
223
+ echo "([e] = exact match, [p] = prefix match)"
224
+ echo ""
185
225
  for pattern in "${ALLOWED_PATTERNS[@]}"; do
186
- echo " • $pattern"
226
+ echo " • $(format_pattern "$pattern")"
187
227
  done
188
228
  echo ""
229
+ echo "([e] = exact match, [p] = prefix match)"
230
+ echo ""
189
231
  echo "If an existing permission pattern can solve your task, use that instead."
190
232
  echo "If you've considered the alternatives and still need this specific command, retry it."
191
233
  echo ""
@@ -59,7 +59,7 @@ PERMISSIONS_CONFIG=$(cat <<'EOF'
59
59
  "Bash(npm list:*)",
60
60
  "Bash(pnpm list:*)",
61
61
 
62
- "Bash(npx rhachet:*)",
62
+ "Bash(npx rhachet roles boot --repo ehmpathy --role mechanic)",
63
63
 
64
64
  "Bash(npm run test:*)",
65
65
  "Bash(npm run test:unit:*)",
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "rhachet-roles-ehmpathy",
3
3
  "author": "ehmpathy",
4
4
  "description": "empathetic software construction roles and skills, via rhachet",
5
- "version": "1.12.0",
5
+ "version": "1.12.1",
6
6
  "repository": "ehmpathy/rhachet-roles-ehmpathy",
7
7
  "homepage": "https://github.com/ehmpathy/rhachet-roles-ehmpathy",
8
8
  "keywords": [