oh-my-customcode 1.1.58 → 1.1.59

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/dist/cli/index.js CHANGED
@@ -243,7 +243,7 @@ var init_package = __esm(() => {
243
243
  workspaces: [
244
244
  "packages/*"
245
245
  ],
246
- version: "1.1.58",
246
+ version: "1.1.59",
247
247
  description: "Batteries-included agent harness for Claude Code",
248
248
  type: "module",
249
249
  bin: {
package/dist/index.js CHANGED
@@ -2539,7 +2539,7 @@ var package_default = {
2539
2539
  workspaces: [
2540
2540
  "packages/*"
2541
2541
  ],
2542
- version: "1.1.58",
2542
+ version: "1.1.59",
2543
2543
  description: "Batteries-included agent harness for Claude Code",
2544
2544
  type: "module",
2545
2545
  bin: {
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "workspaces": [
4
4
  "packages/*"
5
5
  ],
6
- "version": "1.1.58",
6
+ "version": "1.1.59",
7
7
  "description": "Batteries-included agent harness for Claude Code",
8
8
  "type": "module",
9
9
  "bin": {
@@ -50,6 +50,27 @@ Types: feat, fix, docs, style, refactor, test, chore
50
50
  - ALWAYS check `git reflog` before declaring work lost — most destructive ops are recoverable for 30 days
51
51
  - Reference: R001 Destructive Git Commands section, #1146 (v0.136.0 working tree loss incident)
52
52
 
53
+ ## Commit Timeout Budget (#1645)
54
+
55
+ `.husky/pre-commit` 는 **메인 워크트리**에서 typecheck + `bun run lint` + `bun test --coverage`
56
+ 전체 스위트(실측 약 **165초**) + 커버리지 임계값 + CLAUDE.md 카운트 검증까지 순차 실행한다.
57
+ Bash 도구 기본 타임아웃은 **120000ms(2분)** 이라 `git commit` 이 훅 실행 도중
58
+ **exit 143(SIGTERM)** 으로 끊긴다.
59
+
60
+ | 상황 | Bash `timeout` |
61
+ |---|---|
62
+ | 메인 워크트리에서 `git commit` | **≥ 400000** (약 6.7분) |
63
+ | git worktree 에서 `git commit` | 기본값으로 충분 (`.husky/pre-commit` **7-12행**이 `[ -f .git ]` 로 분기해 `bun run typecheck` 만 실행하고 `exit 0` — 전체 스위트는 CI 담당) |
64
+ | `git push` / `gh pr` 등 훅 없는 명령 | 기본값 |
65
+
66
+ **금지**: 타임아웃 회피 목적의 `--no-verify` 사용. 품질 게이트 우회는 상시 금지이며
67
+ 오케스트레이터의 사전 승인이 있을 때만 예외다(R010 「품질 게이트 우회 금지」).
68
+ 훅이 차단하면 우회하지 말고 **차단 사실과 원인을 보고하고 대기**한다.
69
+
70
+ **타임아웃으로 끊긴 경우**: exit 143 은 "커밋 실패"의 증거가 아니다 — 훅이 통과한 뒤
71
+ 커밋이 성사됐을 수도 있다. 재시도 전 `git log -1 --format=%H%n%s` 로 **실제 HEAD 를 실측**하라
72
+ (R020 「Failure/Interrupt Report ≠ Actual Failure」).
73
+
53
74
  ## Push Rules (R016)
54
75
 
55
76
  All pushes require prior mgr-sauron:watch verification. If sauron was not run, REFUSE the push.
@@ -304,8 +304,33 @@ if [ -n "$turn_uuid" ] && [ -f "$MARKER_FILE" ]; then
304
304
  fi
305
305
  fi
306
306
 
307
- advisory_text=$(printf '[R007/R008 Advisory] 직전 응답에서 식별 누락 감지 (R007 헤더=%s, R008 접두사=%s). 이번 응답은 ┌─ Agent: 헤더로 시작하고, 모든 도구 호출에 [agent][model] → Tool: 접두사를 포함하십시오.' \
308
- "$r007_violations" "$r008_violations")
307
+ # ── 위반 문구 조립 (#1643 — 판정 로직 불변, 레이블 의미를 문구 자체가 드러내도록 정정) ──
308
+ # 이전 문구 "R007 헤더=%s, R008 접두사=%s"의 %s는 위반 "건수"(0=컴플라이언트)였는데, 레이블
309
+ # "헤더"/"접두사"가 "개수"로 오독되어 "R007 헤더=0"이 "헤더가 없다"로 잘못 읽혔다(#1643 진단
310
+ # 확정 — 실제로는 헤더가 정상 존재하는 컴플라이언트 상태였다). 값이 위반 건수라는 것을 문구
311
+ # 자체가 드러내도록 "누락 N건"으로 표현하고, 위반이 없는 차원은 문구에서 아예 제외한다 — 0건인
312
+ # 차원을 언급하면 그 차원도 위반처럼 오독될 수 있기 때문이다.
313
+ violation_desc=""
314
+ instruction=""
315
+ if [ "$r007_violations" -gt 0 ]; then
316
+ violation_desc="R007 에이전트 식별 헤더 누락 ${r007_violations}건"
317
+ instruction="이번 응답은 ┌─ Agent: 헤더로 시작하십시오."
318
+ fi
319
+ if [ "$r008_violations" -gt 0 ]; then
320
+ if [ -n "$violation_desc" ]; then
321
+ violation_desc="${violation_desc}, R008 도구 식별 접두사 누락 ${r008_violations}건"
322
+ instruction="이번 응답은 ┌─ Agent: 헤더로 시작하고, 모든 도구 호출에 [agent][model] → Tool: 접두사를 포함하십시오."
323
+ else
324
+ violation_desc="R008 도구 식별 접두사 누락 ${r008_violations}건"
325
+ instruction="모든 도구 호출에 [agent][model] → Tool: 접두사를 포함하십시오."
326
+ fi
327
+ fi
328
+
329
+ if [ -n "$violation_desc" ]; then
330
+ advisory_text="[R007/R008 Advisory] 직전 응답에서 ${violation_desc} 감지. ${instruction}"
331
+ else
332
+ advisory_text="[R007/R008 Advisory]"
333
+ fi
309
334
 
310
335
  if [ "$r008_reverse" -gt 0 ]; then
311
336
  advisory_text="${advisory_text} [R009 Self-Check #6] 직전 턴은 도구 호출 ${r008_reverse}건을 예고하고도 tool_use 블록 없이 종료했습니다 — 예고한 호출을 지금 실행하거나, 실행하지 않기로 한 사유를 명시하십시오."
@@ -96,18 +96,66 @@ if [ -d "wiki" ]; then
96
96
  fi
97
97
 
98
98
  # ─── Check 6: Broken skill references (lightweight) ───
99
+ # Parses BOTH frontmatter forms (#1640):
100
+ # inline : skills: [a, b]
101
+ # block : skills:
102
+ # - a
103
+ # - b
104
+ # Emits one skill name per line. Scans the YAML frontmatter only (stops at the
105
+ # closing "---"), so a "skills:" line in the agent body is never parsed.
106
+ parse_agent_skills() {
107
+ awk '
108
+ BEGIN {
109
+ SQ = sprintf("%c", 39); DQ = sprintf("%c", 34)
110
+ infm = 0; inskills = 0
111
+ }
112
+ function clean(s) {
113
+ sub(/[[:space:]]*#.*$/, "", s)
114
+ gsub(SQ, "", s); gsub(DQ, "", s)
115
+ gsub(/[[:space:]]/, "", s)
116
+ return s
117
+ }
118
+ NR == 1 { if ($0 ~ /^---[[:space:]]*$/) infm = 1; next }
119
+ infm == 0 { exit }
120
+ /^---[[:space:]]*$/ { exit }
121
+ inskills == 1 {
122
+ if ($0 ~ /^[[:space:]]+-[[:space:]]*/) {
123
+ item = $0
124
+ sub(/^[[:space:]]+-[[:space:]]*/, "", item)
125
+ item = clean(item)
126
+ if (item != "") print item
127
+ next
128
+ }
129
+ if ($0 ~ /^[[:space:]]*$/) next
130
+ inskills = 0
131
+ }
132
+ /^skills:/ {
133
+ rest = $0
134
+ sub(/^skills:[[:space:]]*/, "", rest)
135
+ sub(/[[:space:]]*#.*$/, "", rest)
136
+ if (rest ~ /^\[/) {
137
+ sub(/^\[/, "", rest); sub(/\][[:space:]]*$/, "", rest)
138
+ n = split(rest, arr, ",")
139
+ for (i = 1; i <= n; i++) {
140
+ s = clean(arr[i])
141
+ if (s != "") print s
142
+ }
143
+ } else if (rest == "") {
144
+ inskills = 1
145
+ }
146
+ next
147
+ }
148
+ ' "$1"
149
+ }
150
+
99
151
  broken_refs=0
100
152
  for agent in .claude/agents/*.md; do
101
- skills_line=$(grep -E '^skills:' "$agent" 2>/dev/null | head -1)
102
- if [ -n "$skills_line" ]; then
103
- skills=$(echo "$skills_line" | sed 's/skills: *\[//;s/\]//;s/,/ /g;s/"//g' | tr -d "'")
104
- for skill in $skills; do
105
- skill=$(echo "$skill" | tr -d ' ')
106
- if [ -n "$skill" ] && [ ! -f ".claude/skills/${skill}/SKILL.md" ]; then
107
- broken_refs=$((broken_refs + 1))
108
- fi
109
- done
110
- fi
153
+ [ -f "$agent" ] || continue
154
+ while IFS= read -r skill; do
155
+ if [ -n "$skill" ] && [ ! -f ".claude/skills/${skill}/SKILL.md" ]; then
156
+ broken_refs=$((broken_refs + 1))
157
+ fi
158
+ done <<< "$(parse_agent_skills "$agent")"
111
159
  done
112
160
  if [ "$broken_refs" -gt 0 ]; then
113
161
  add_issue "broken-refs:${broken_refs} broken skill reference(s) in agent frontmatter"
@@ -44,6 +44,23 @@ is_readonly_single_command() {
44
44
  local w2="${parts[1]:-}"
45
45
  local w3="${parts[2]:-}"
46
46
 
47
+ # Variable assignment prefix: "VAR=value" or "VAR=value cmd args".
48
+ # A bare assignment has no side effect outside the shell; when followed by a
49
+ # command, classify that command instead. Command substitutions inside the
50
+ # RHS were already validated and replaced by is_readonly_bash_command (#1641).
51
+ case "$w1" in
52
+ [A-Za-z_]*=*)
53
+ if [ "${#parts[@]}" -le 1 ]; then
54
+ echo "true"
55
+ return 0
56
+ fi
57
+ local rest_cmd="${cmd#*"$w1"}"
58
+ rest_cmd="$(printf '%s' "$rest_cmd" | sed -e 's/^[[:space:]]*//')"
59
+ is_readonly_single_command "$rest_cmd"
60
+ return 0
61
+ ;;
62
+ esac
63
+
47
64
  case "$w1" in
48
65
  ls|cat|head|tail|grep|rg|wc|jq|md5|md5sum|type|command|which|echo|printf|pwd|date)
49
66
  echo "true"
@@ -77,7 +94,7 @@ is_readonly_single_command() {
77
94
  *) ok="false" ;;
78
95
  esac
79
96
  done
80
- echo "$ok"
97
+ printf '%s\n' "$ok"
81
98
  ;;
82
99
  *)
83
100
  # fetch and all other subcommands (checkout/merge/rebase/push/...) => write
@@ -116,29 +133,172 @@ is_readonly_single_command() {
116
133
  esac
117
134
  }
118
135
 
136
+ # Maximum recursion depth for nested command substitution / loop bodies.
137
+ _RO_MAX_DEPTH=5
138
+ # Maximum command length that is parsed at all (see Step 0 below).
139
+ _RO_MAX_COMMAND_LEN=4000
140
+
119
141
  is_readonly_bash_command() {
120
142
  local cmd="$1"
143
+ local depth="${2:-0}"
144
+
145
+ if [ "$depth" -gt "$_RO_MAX_DEPTH" ]; then
146
+ echo "false"
147
+ return 0
148
+ fi
149
+
150
+ # --- Step 0: length cap (M-4). The "$(...)" balance scan below walks the
151
+ # remainder of the command ONE CHARACTER AT A TIME and rebuilds "$inner" on
152
+ # every iteration, which is O(n^2) in the substitution's length (measured:
153
+ # 5 KB => 0.9 s, 20 KB => 13.6 s of latency on a PostToolUse hook).
154
+ # "$raw_command" is the only unbounded field left after the cap on
155
+ # target_key, so cap it here. Nothing legitimately read-only is 4 KB long;
156
+ # anything over the cap is classified as a write, i.e. the conservative side
157
+ # (a read-only classification only ever RELAXES blocking).
158
+ if [ "${#cmd}" -gt "$_RO_MAX_COMMAND_LEN" ]; then
159
+ echo "false"
160
+ return 0
161
+ fi
162
+
121
163
  cmd="$(printf '%s' "$cmd" | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')"
122
164
  if [ -z "$cmd" ]; then
123
165
  echo "false"
124
166
  return 0
125
167
  fi
126
168
 
127
- # Truly ambiguous constructs: redirection, command/process substitution, or
128
- # "||" (conditional-OR — intentionally NOT decomposed into segments, since
129
- # its branch that actually runs depends on the first segment's exit code)
130
- # => always treated as write.
169
+ # --- Step 1: process substitution "<(...)" stays ambiguous => write. ---
170
+ case "$cmd" in
171
+ *'<('*)
172
+ echo "false"
173
+ return 0
174
+ ;;
175
+ esac
176
+
177
+ # --- Step 2: command substitution "$(...)" / backticks.
178
+ # Rather than treating them as an automatic write (#1641), extract the inner
179
+ # command, classify it RECURSIVELY, and replace the substitution with the
180
+ # inert placeholder "SUBST". A write inside the substitution (e.g.
181
+ # "$(rm -rf /tmp/x)", "$(git push)") still makes the whole command a write.
182
+ while :; do
183
+ case "$cmd" in
184
+ *'$('*)
185
+ local before="${cmd%%'$('*}"
186
+ local after="${cmd#*'$('}"
187
+ # Balance-aware scan for the matching ")".
188
+ local inner="" rest="" d=1 i ch
189
+ for ((i = 0; i < ${#after}; i++)); do
190
+ ch="${after:$i:1}"
191
+ if [ "$ch" = "(" ]; then
192
+ d=$((d + 1))
193
+ elif [ "$ch" = ")" ]; then
194
+ d=$((d - 1))
195
+ if [ "$d" -eq 0 ]; then
196
+ rest="${after:$((i + 1))}"
197
+ break
198
+ fi
199
+ fi
200
+ inner="${inner}${ch}"
201
+ done
202
+ if [ "$d" -ne 0 ]; then
203
+ # Unbalanced => unparseable => conservative write.
204
+ echo "false"
205
+ return 0
206
+ fi
207
+ if [ "$(is_readonly_bash_command "$inner" $((depth + 1)))" != "true" ]; then
208
+ echo "false"
209
+ return 0
210
+ fi
211
+ cmd="${before}SUBST${rest}"
212
+ ;;
213
+ *'`'*)
214
+ # Backticks do not nest; take the text between the first pair.
215
+ local b_before="${cmd%%'`'*}"
216
+ local b_after="${cmd#*'`'}"
217
+ case "$b_after" in
218
+ *'`'*) ;;
219
+ *) echo "false"; return 0 ;;
220
+ esac
221
+ local b_inner="${b_after%%'`'*}"
222
+ local b_rest="${b_after#*'`'}"
223
+ if [ "$(is_readonly_bash_command "$b_inner" $((depth + 1)))" != "true" ]; then
224
+ echo "false"
225
+ return 0
226
+ fi
227
+ cmd="${b_before}SUBST${b_rest}"
228
+ ;;
229
+ *)
230
+ break
231
+ ;;
232
+ esac
233
+ done
234
+
235
+ # --- Step 3: strip harmless redirections BEFORE the ">" write check.
236
+ # "2>&1", ">/dev/null", "2>/dev/null", "1>/dev/null", "&>/dev/null" produce no
237
+ # observable side effect. Any OTHER ">" (a real file write) remains a write.
238
+ local stripped
239
+ stripped="$(printf '%s' "$cmd" \
240
+ | sed -E 's/[0-9]?>&[0-9]/ /g; s#[0-9]?&?>[[:space:]]*/dev/null# #g')"
241
+ case "$stripped" in
242
+ *'>'*)
243
+ echo "false"
244
+ return 0
245
+ ;;
246
+ esac
247
+ cmd="$stripped"
248
+
249
+ # --- Step 4: "||" is still NOT decomposed (which branch runs depends on the
250
+ # first segment's exit code) => write. Preserved from #1629.
131
251
  case "$cmd" in
132
- *'>'*|*'||'*|*'$('*|*'`'*|*'<('*)
252
+ *'||'*)
133
253
  echo "false"
134
254
  return 0
135
255
  ;;
136
256
  esac
137
257
 
138
- # Compound command: split on "&&", ";", or a single "|" into segments and
258
+ # --- Step 5: for / while loops (#1641).
259
+ # Normalize ";do" / ";done" spacing, then classify the header and the
260
+ # "do ... done" body separately. Both must be read-only.
261
+ case "$cmd" in
262
+ for\ *|while\ *)
263
+ local norm
264
+ norm="$(printf '%s' "$cmd" | sed -E 's/;[[:space:]]*do([[:space:]]|$)/ ; do /g; s/;[[:space:]]*done/ ; done/g')"
265
+ case "$norm" in
266
+ *' do '*'done'*) ;;
267
+ *) echo "false"; return 0 ;;
268
+ esac
269
+ local head="${norm%% do *}"
270
+ local tail_part="${norm#* do }"
271
+ local body="${tail_part%done*}"
272
+ head="$(printf '%s' "$head" | sed -e 's/[[:space:]]*;[[:space:]]*$//')"
273
+ body="$(printf '%s' "$body" | sed -e 's/[[:space:]]*;[[:space:]]*$//')"
274
+
275
+ case "$head" in
276
+ # "for VAR in <words>" — pure iteration, no side effect. The <words>
277
+ # already had any substitution validated in Step 2.
278
+ for\ [A-Za-z_]*\ in\ *)
279
+ ;;
280
+ while\ *)
281
+ # The while CONDITION is a real command — classify it.
282
+ local wcond="${head#while }"
283
+ if [ "$(is_readonly_bash_command "$wcond" $((depth + 1)))" != "true" ]; then
284
+ echo "false"
285
+ return 0
286
+ fi
287
+ ;;
288
+ *)
289
+ echo "false"
290
+ return 0
291
+ ;;
292
+ esac
293
+
294
+ is_readonly_bash_command "$body" $((depth + 1))
295
+ return 0
296
+ ;;
297
+ esac
298
+
299
+ # --- Step 6: compound command — split on "&&", ";", or a single "|" and
139
300
  # require EVERY segment to be read-only (#1629). An empty segment (e.g. a
140
- # trailing separator) is treated as ambiguous => write, same as any
141
- # segment that fails single-command classification.
301
+ # trailing separator) is ambiguous => write.
142
302
  if [[ "$cmd" == *'&&'* || "$cmd" == *';'* || "$cmd" == *'|'* ]]; then
143
303
  local normalized="$cmd"
144
304
  normalized="${normalized//&&/$'\n'}"
@@ -167,15 +327,67 @@ input=$(cat)
167
327
 
168
328
  # Extract tool info
169
329
  tool_name=$(printf '%s' "$input" | jq -r '.tool_name // "unknown"')
170
- # 300 (not 120): a 120-char cutoff let two genuinely different long Bash
171
- # commands collide on their shared 120-char prefix, causing a false-positive
172
- # same-path/same-tool+target hard-block. 300 chars covers the vast majority
173
- # of real commands without their differing tail being cut off (#1629).
174
- file_path=$(printf '%s' "$input" | jq -r '.tool_input.file_path // .tool_input.command // ""' | head -c 300)
330
+ # Bash commands are NOT files. Feeding tool_input.command into file_path made
331
+ # the hard-block message report a command fragment as a "file" and let Check 1
332
+ # ("Same file ... edited") fire on Bash at all (#1641). Keep the command text in
333
+ # a SEPARATE field (target_key) so tool+target repetition detection (Check 3 /
334
+ # Signal 3) still works, while the file-oriented checks see nothing for Bash.
335
+ #
336
+ # 1000 (was 300, originally 120): a short cutoff let two genuinely different
337
+ # long Bash commands collide on their shared prefix, causing a false-positive
338
+ # same-path/same-tool+target hard-block (#1629). Truncation alone can never
339
+ # remove that collision class, so truncate_key() ALSO appends the ORIGINAL
340
+ # length: two values that share the capped prefix but differ in total length
341
+ # no longer produce the same key (M-3).
342
+ TARGET_KEY_CAP=1000
343
+
344
+ truncate_key() {
345
+ local v="$1"
346
+ if [ "${#v}" -gt "$TARGET_KEY_CAP" ]; then
347
+ printf '%s' "${v:0:$TARGET_KEY_CAP}#len=${#v}"
348
+ else
349
+ printf '%s' "$v"
350
+ fi
351
+ }
352
+
353
+ if [ "$tool_name" = "Bash" ]; then
354
+ file_path=""
355
+ # ".tool_input.file_path" is a defensive fallback only: the real Bash tool has
356
+ # no file_path parameter, but a caller (or a test fixture) may still supply one
357
+ # as the target identifier. The command text wins whenever it is present.
358
+ target_key=$(truncate_key "$(printf '%s' "$input" | jq -r '.tool_input.command // .tool_input.file_path // ""')")
359
+ else
360
+ file_path_full=$(printf '%s' "$input" | jq -r '.tool_input.file_path // ""')
361
+ # file_path is display/guard only (basename in the messages); target_key is
362
+ # the value matched against history, so only it carries the length tag.
363
+ file_path=$(printf '%s' "$file_path_full" | head -c "$TARGET_KEY_CAP")
364
+ target_key=$(truncate_key "$file_path_full")
365
+ fi
175
366
  is_error=$(printf '%s' "$input" | jq -r '.tool_output.is_error // false')
176
367
  output_preview=$(printf '%s' "$input" | jq -r '.tool_output.output // ""' | head -c 200)
177
368
  raw_command=$(printf '%s' "$input" | jq -r '.tool_input.command // ""')
178
369
 
370
+ # Distinguish "the same file edited 3 times with DIFFERENT content" (a normal
371
+ # incremental-edit workflow — the #1641 false positive) from "the same edit
372
+ # repeated 3 times" (a genuine stuck loop). Only the latter should hard-block.
373
+ # Alphanumerics-only + length cap: deterministic, platform-independent (no
374
+ # md5sum, absent on macOS) and safe to embed in a grep pattern.
375
+ edit_hash=""
376
+ if [ "$tool_name" = "Edit" ] || [ "$tool_name" = "Write" ]; then
377
+ edit_hash=$(printf '%s' "$input" \
378
+ | jq -r '(.tool_input.old_string // .tool_input.content // .tool_input.new_string // "")
379
+ | gsub("[^A-Za-z0-9]"; "") | .[0:120]')
380
+ fi
381
+
382
+ # History entries are written by jq, so their "path" values are JSON-ENCODED.
383
+ # Matching them requires the SAME encoding, not the raw text: a raw value
384
+ # containing a quote (common in Bash commands) can never match the encoded
385
+ # form. The previous BRE escaping was doubly broken — in POSIX BRE "( ) + ? { |"
386
+ # are literals, so escaping them turned them INTO operators and silently
387
+ # stopped matching. Encode once here and match with grep -F (fixed string).
388
+ target_key_json=$(jq -n --arg v "$target_key" '$v')
389
+ path_match="\"path\":${target_key_json}"
390
+
179
391
  is_readonly="false"
180
392
  if [ "$tool_name" = "Bash" ]; then
181
393
  is_readonly=$(is_readonly_bash_command "$raw_command")
@@ -190,18 +402,22 @@ timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)
190
402
  # Generate error hash for deduplication (first 50 chars of error)
191
403
  error_hash=""
192
404
  if [ "$is_error" = "true" ]; then
193
- error_hash=$(echo "$output_preview" | head -c 50 | md5sum 2>/dev/null | cut -d' ' -f1 || echo "unknown")
405
+ error_hash=$(printf '%s' "$output_preview" | head -c 50 | md5sum 2>/dev/null | cut -d' ' -f1 || printf '%s\n' "unknown")
194
406
  fi
195
407
 
408
+ # "path" holds $target_key — a file path for file tools, the command text for
409
+ # Bash (#1641). Keeping Bash commands in this field preserves Check 3 / Signal 3
410
+ # repetition detection while file_path stays empty for Bash.
196
411
  entry=$(jq -cn \
197
412
  --arg ts "$timestamp" \
198
413
  --arg tool "$tool_name" \
199
- --arg path "$file_path" \
414
+ --arg path "$target_key" \
200
415
  --arg err "$is_error" \
201
416
  --arg hash "$error_hash" \
417
+ --arg ehash "$edit_hash" \
202
418
  --arg preview "$output_preview" \
203
419
  --arg readonly "$is_readonly" \
204
- '{timestamp: $ts, tool: $tool, path: $path, is_error: $err, error_hash: $hash, preview: $preview, readonly: $readonly}')
420
+ '{timestamp: $ts, tool: $tool, path: $path, is_error: $err, error_hash: $hash, edit_hash: $ehash, preview: $preview, readonly: $readonly}')
205
421
 
206
422
  printf '%s\n' "$entry" >> "$HISTORY_FILE"
207
423
 
@@ -237,7 +453,7 @@ recovery=""
237
453
 
238
454
  # Signal 1: Repeated error (same error_hash 3+ times in last 10 entries)
239
455
  if [ "$is_error" = "true" ] && [ -n "$error_hash" ]; then
240
- error_repeat=$(tail -10 "$HISTORY_FILE" | grep -c "\"error_hash\":\"${error_hash}\"" 2>/dev/null || echo "0")
456
+ error_repeat=$(tail -10 "$HISTORY_FILE" | grep -c "\"error_hash\":\"${error_hash}\"" 2>/dev/null || printf '%s\n' "0")
241
457
  if [ "$error_repeat" -ge 3 ]; then
242
458
  stuck_detected=true
243
459
  signal_type="Repeated error"
@@ -251,12 +467,12 @@ fi
251
467
  # Signal 2: Edit loop (same file edited 3+ times in last 8 entries)
252
468
  if [ "$stuck_detected" = false ] && { [ "$tool_name" = "Edit" ] || [ "$tool_name" = "Write" ]; }; then
253
469
  if [ -n "$file_path" ]; then
254
- escaped_path=$(echo "$file_path" | sed 's/[.[\*^$()+?{|]/\\&/g')
255
- edit_repeat=$(tail -8 "$HISTORY_FILE" | grep -c "\"path\":\"${escaped_path}\"" 2>/dev/null || echo "0")
470
+ edit_repeat=$(tail -8 "$HISTORY_FILE" | grep -cF -e "$path_match" 2>/dev/null || true)
471
+ [ -n "$edit_repeat" ] || edit_repeat=0
256
472
  if [ "$edit_repeat" -ge 3 ]; then
257
473
  stuck_detected=true
258
474
  signal_type="Edit loop"
259
- pattern_desc="$(basename "$file_path") edited ${edit_repeat} times in last 8 calls"
475
+ pattern_desc="$(basename -- "$file_path") edited ${edit_repeat} times in last 8 calls"
260
476
  occurrence_count=$edit_repeat
261
477
  threshold=3
262
478
  recovery="Try a different file or approach instead of re-editing"
@@ -271,7 +487,7 @@ fi
271
487
  # calls (git status / gh view / ls / ...) doesn't inflate the "same tool
272
488
  # called N times" advisory.
273
489
  if [ "$stuck_detected" = false ] && [ "$is_readonly" != "true" ]; then
274
- tool_repeat=$(tail -8 "$HISTORY_FILE" | grep -v "\"readonly\":\"true\"" | grep -c "\"tool\":\"${tool_name}\"" 2>/dev/null || echo "0")
490
+ tool_repeat=$(tail -8 "$HISTORY_FILE" | grep -v "\"readonly\":\"true\"" | grep -c "\"tool\":\"${tool_name}\"" 2>/dev/null || printf '%s\n' "0")
275
491
  if [ "$tool_repeat" -ge 5 ]; then
276
492
  stuck_detected=true
277
493
  signal_type="Tool loop"
@@ -302,38 +518,64 @@ hard_block_reason=""
302
518
 
303
519
  if [ -f "$HISTORY_FILE" ]; then
304
520
  last_n=$(tail -"$HARD_BLOCK_THRESHOLD" "$HISTORY_FILE" 2>/dev/null)
305
- last_n_count=$(echo "$last_n" | wc -l | tr -d ' ')
521
+ last_n_count=$(printf '%s\n' "$last_n" | wc -l | tr -d ' ')
306
522
 
307
523
  if [ "$last_n_count" -ge "$HARD_BLOCK_THRESHOLD" ]; then
308
- # Check 1: Same file edited HARD_BLOCK_THRESHOLD+ times consecutively
524
+ # Check 1: Same file edited with the SAME content HARD_BLOCK_THRESHOLD+
525
+ # times consecutively. Narrowed in #1641: three DIFFERENT edits to one file
526
+ # is a normal incremental workflow (observed repeatedly on wiki/rule/doc
527
+ # files), not a stuck loop — only an IDENTICAL repeated edit blocks. Both
528
+ # the path AND the edit_hash must match.
309
529
  # (skip when current call is a read-only Bash command — repeated read-only
310
530
  # polling of the same target is not a stuck-loop signal; see #1625)
531
+ # Bash never reaches here — file_path is empty for Bash (#1641), and
532
+ # edit_hash is empty too; repeated Bash commands are handled by Check 3
533
+ # via target_key instead.
311
534
  if [ "$is_readonly" != "true" ] && [ -n "$file_path" ]; then
312
- escaped_path=$(echo "$file_path" | sed 's/[.[\*^$()+?{|]/\\&/g')
313
- consecutive_file=$(echo "$last_n" | grep -c "\"path\":\"${escaped_path}\"" 2>/dev/null || echo "0")
535
+ consecutive_file=$(printf '%s\n' "$last_n" \
536
+ | grep -F -e "$path_match" \
537
+ | grep -cF -e "\"edit_hash\":\"${edit_hash}\"" 2>/dev/null || true)
538
+ [ -n "$consecutive_file" ] || consecutive_file=0
314
539
  if [ "$consecutive_file" -ge "$HARD_BLOCK_THRESHOLD" ]; then
315
540
  hard_block=true
316
- hard_block_reason="Same file ($(basename "$file_path")) edited ${consecutive_file} consecutive times"
541
+ hard_block_reason="Same file ($(basename -- "$file_path")) received the identical edit ${consecutive_file} consecutive times"
317
542
  fi
318
543
  fi
319
544
 
320
545
  # Check 2: Same error repeated HARD_BLOCK_THRESHOLD+ times consecutively
321
546
  if [ "$hard_block" = false ] && [ "$is_error" = "true" ] && [ -n "$error_hash" ]; then
322
- consecutive_error=$(echo "$last_n" | grep -c "\"error_hash\":\"${error_hash}\"" 2>/dev/null || echo "0")
547
+ consecutive_error=$(printf '%s\n' "$last_n" | grep -c "\"error_hash\":\"${error_hash}\"" 2>/dev/null || printf '%s\n' "0")
323
548
  if [ "$consecutive_error" -ge "$HARD_BLOCK_THRESHOLD" ]; then
324
549
  hard_block=true
325
550
  hard_block_reason="Same error repeated ${consecutive_error} consecutive times"
326
551
  fi
327
552
  fi
328
553
 
329
- # Check 3: Same tool+target combination HARD_BLOCK_THRESHOLD+ times consecutively
554
+ # Check 3: Same tool+target combination HARD_BLOCK_THRESHOLD+ times
555
+ # consecutively. Uses target_key (a file path for file tools, the command
556
+ # text for Bash) so repeated identical Bash commands are still blocked
557
+ # after file_path was emptied for Bash (#1641).
330
558
  # (skip when current call is a read-only Bash command — see Check 1 note)
331
- if [ "$hard_block" = false ] && [ "$is_readonly" != "true" ] && [ -n "$file_path" ]; then
332
- escaped_path=$(echo "$file_path" | sed 's/[.[\*^$()+?{|]/\\&/g')
333
- consecutive_tool_target=$(echo "$last_n" | grep "\"tool\":\"${tool_name}\"" | grep -c "\"path\":\"${escaped_path}\"" 2>/dev/null || echo "0")
559
+ # The edit_hash filter mirrors Check 1's #1641 narrowing: without it this
560
+ # check re-creates the very false positive Check 1 was narrowed to remove
561
+ # (tool=Edit + same path fires at 3 regardless of content). For Bash the
562
+ # filter is a no-op — every Bash history entry carries edit_hash "".
563
+ if [ "$hard_block" = false ] && [ "$is_readonly" != "true" ] && [ -n "$target_key" ]; then
564
+ consecutive_tool_target=$(printf '%s\n' "$last_n" \
565
+ | grep -F -e "\"tool\":\"${tool_name}\"" \
566
+ | grep -F -e "$path_match" \
567
+ | grep -cF -e "\"edit_hash\":\"${edit_hash}\"" 2>/dev/null || true)
568
+ [ -n "$consecutive_tool_target" ] || consecutive_tool_target=0
334
569
  if [ "$consecutive_tool_target" -ge "$HARD_BLOCK_THRESHOLD" ]; then
335
570
  hard_block=true
336
- hard_block_reason="${tool_name} called on $(basename "$file_path") ${consecutive_tool_target} consecutive times"
571
+ # Do NOT call basename() on a Bash target: a command is not a path, and
572
+ # basename() on command text produced the misleading "Same file (pr)"
573
+ # style message reported in #1641.
574
+ if [ "$tool_name" = "Bash" ]; then
575
+ hard_block_reason="Identical Bash command repeated ${consecutive_tool_target} times: $(printf '%s' "$target_key" | head -c 60)"
576
+ else
577
+ hard_block_reason="${tool_name} called on $(basename -- "$target_key") ${consecutive_tool_target} consecutive times"
578
+ fi
337
579
  fi
338
580
  fi
339
581
  fi
@@ -428,7 +428,17 @@ The Agent tool defaults to `mode: "acceptEdits"`, which overrides agent frontmat
428
428
  ### Self-Check
429
429
 
430
430
  Before spawning any agent:
431
- 1. Does the Agent tool call include `mode: "bypassPermissions"`? → YES: proceed → NO: add it
431
+ 1. **유효 permission mode 확인** — per-call `mode` 파라미터는 v2.1.212+ 에서 무시되고,
432
+ **프로젝트 scope `permissions.defaultMode` 는 v2.1.257+ 에서도 무시된다(#1644)**.
433
+ 무인 실행 전 실측할 것: `jq -r '.permissions.defaultMode // "unset"' ~/.claude/settings.json`
434
+ (user scope) — 이 값 또는 `--permission-mode` 실행 플래그만이 유효하다.
435
+ bypassPermissions 가 아니면 프롬프트 발생을 전제로 계획한다.
436
+ 하위 호환을 위해 per-call `mode: "bypassPermissions"` 는 계속 포함하되,
437
+ **그 존재를 무인 실행의 증거로 삼지 않는다**(R020 "attempt ≠ outcome").
438
+ 실측(2026-09-03, `claude -p --debug-file`): `[WARN] settings defaultMode "bypassPermissions"
439
+ ignored — only policy/user/flag settings may grant bypass mode (projectSettings and
440
+ localSettings are repo-controllable)` — 무시 동작이 직접 실증되었다. 프로젝트 settings에는
441
+ `permissions._comment_defaultMode` 안내 키가 추가되었다(v1.1.59).
432
442
  2. Is this a new skill that spawns agents? → Add Permission Mode section
433
443
 
434
444
  ### Common Violation
@@ -133,3 +133,10 @@ Origin: #1582. Cross-ref: R018(Member TaskUpdate Discipline 대체 규약), R020
133
133
  > Canonical source: R010 (MUST-orchestrator-coordination.md) "Universal bypassPermissions" owns the full requirement, rationale, self-check, and version history. Core rule: always pass `mode: "bypassPermissions"` explicitly on every Agent tool call — the Agent tool's default `mode` (`acceptEdits`) overrides agent frontmatter `permissionMode` and causes prompts during unattended execution. Skills that spawn agents MUST include this in their Agent tool call instructions. See R010 for details.
134
134
 
135
135
  > **v2.1.212+**: CC가 Agent(구 Task) tool의 `mode` 파라미터를 deprecated 처리했습니다(이제 무시) — subagent는 부모 세션의 permission mode를 기본 상속합니다. 위 canonical 요약의 default `mode`(`acceptEdits`)가 frontmatter `permissionMode`를 override한다는 서술 및 항상 `mode: "bypassPermissions"`를 넘기라는 요건은 이 버전부터 stale이며(파라미터가 무시됨), 무인 실행의 실질 게이트는 부모 세션의 permission mode입니다. 요건 재조정은 R010 "Universal bypassPermissions"가 canonical — R002는 이 flag만 유지합니다.
136
+
137
+ > **v2.1.257+**: 프로젝트 scope `permissions.defaultMode` 가 무시됩니다(user/managed scope 또는
138
+ > `--permission-mode` 플래그만 유효). 위 v2.1.212 노트가 "무인 실행의 실질 게이트는 부모 세션의
139
+ > permission mode"라고 정정했는데, **그 부모 세션 모드를 프로젝트 settings로 지정하는 경로가 이
140
+ > 버전에서 끊겼습니다** — 이 파일 상단 「Deny Rule Glob Patterns」의 v2.1.214 노트(allow 규칙만
141
+ > `<cwd>`로 좁아진 비대칭)와 같은 계열의 **project-scope 축소** 흐름입니다. Canonical owner 는
142
+ > R010 "Universal bypassPermissions" — 상세와 실측 절차는 그쪽을 참조합니다. Origin: #1644.
@@ -169,6 +169,22 @@ If any of those underlying skills evolve, FSD automatically benefits — its onl
169
169
 
170
170
  When this skill delegates work via Agent tool calls, ALL Agent tool calls MUST include `mode: "bypassPermissions"` per R010 Universal bypassPermissions.
171
171
 
172
+ ⚠ **그 파라미터는 CC v2.1.212+ 에서 무시되며, 프로젝트 scope `permissions.defaultMode` 역시
173
+ CC v2.1.257+ 에서 무시된다(#1644).** 즉 위 지시를 지켰다는 사실은 **무인 실행의 증거가 아니다**.
174
+ 자율 루프 진입 전에 유효 모드를 실측한다:
175
+
176
+ ```bash
177
+ jq -r '.permissions.defaultMode // "unset"' ~/.claude/settings.json 2>/dev/null || echo unset
178
+ ```
179
+
180
+ `bypassPermissions` 가 아니면 루프 도중 permission 프롬프트로 정지할 수 있으므로,
181
+ `--permission-mode bypassPermissions` 로 재시작하거나 사람이 지켜보는 실행임을 전제한다.
182
+ (파이프라인 쪽 배선은 `pipeline auto-dev` 의 pre-triage Phase 0.5 가 담당한다.)
183
+
184
+ ⚠ **커밋 위임 타임아웃 (#1645)**: 메인 워크트리의 `.husky/pre-commit` 이 전체 테스트
185
+ 스위트(약 165초)를 돌리므로, `git commit` 을 위임할 때는 Bash `timeout: 400000` 을 명시한다.
186
+ 기본값 120000ms 로는 exit 143(SIGTERM)으로 끊긴다. `--no-verify` 우회는 금지(R010).
187
+
172
188
  ## Artifact Output
173
189
 
174
190
  Artifacts from each iteration follow the conventions of the constituent skills:
@@ -54,6 +54,30 @@ steps:
54
54
  "[pre-triage] WARNING: Issue #N references vX.Y.Z (not in git tags) — body may be stale"
55
55
  - Output all warnings as advisory log; do NOT halt
56
56
 
57
+ Phase 0.5 — Measure the EFFECTIVE permission mode (advisory, do NOT halt).
58
+
59
+ Why: CC v2.1.257 stopped honoring `permissions.defaultMode` declared in PROJECT scope
60
+ (`.claude/settings.json` / `.claude/settings.local.json`). Only user/managed scope or an
61
+ explicit `--permission-mode` flag takes effect. R010 「Universal bypassPermissions」 assumes
62
+ the parent session runs unattended under bypassPermissions; if that assumption is silently
63
+ false, this pipeline stalls on a permission prompt mid-run with no diagnostic (#1644).
64
+
65
+ 1. Read the user-scope setting (project scope is NOT authoritative on v2.1.257+):
66
+ user_mode=$(jq -r '.permissions.defaultMode // "unset"' ~/.claude/settings.json 2>/dev/null || echo "unset")
67
+
68
+ 2. The `--permission-mode` launch flag cannot be read from inside the session. Treat it as
69
+ UNKNOWN — never infer that it was passed.
70
+
71
+ 3. Report and, when not bypassPermissions, warn:
72
+ - user_mode == "bypassPermissions":
73
+ report: "[pre-triage] effective permission mode: bypassPermissions (user scope)"
74
+ - otherwise:
75
+ stderr warning: "[pre-triage] WARNING: effective permission mode is <user_mode>; unattended run may prompt. Project-scope permissions.defaultMode is IGNORED on CC v2.1.257+ (#1644). To run unattended, launch with --permission-mode bypassPermissions or set it in user-scope ~/.claude/settings.json."
76
+ - Do NOT halt (advisory only — a prompted run still completes with a human present).
77
+
78
+ 4. Do NOT read, echo, or modify any credential material while checking settings — read the
79
+ single `permissions.defaultMode` field only (R001).
80
+
57
81
  Phase 1 — Ensure required labels exist, then scan issues.
58
82
 
59
83
  1. Create labels if missing (idempotent):
@@ -297,6 +321,14 @@ steps:
297
321
  develop-bound commit auto-closes the issue on push — BEFORE release/tag/publish (observed v1.1.38,
298
322
  07:49:26Z). Close keywords belong ONLY in the release-stage PR body (see release step 3.b) — auto-tag.yml
299
323
  greps the PR body, not commit messages, to decide which issues to close.
324
+ ⚠ Bash timeout (#1645): the main-worktree `.husky/pre-commit` runs typecheck + lint +
325
+ the FULL `bun test --coverage` suite (~165s measured) before the commit lands. The Bash
326
+ tool's default timeout is 120000ms, so a `git commit` delegation with the default budget
327
+ is killed mid-hook with exit 143 (SIGTERM). Delegate `git commit` with an explicit
328
+ `timeout: 400000` (≈6.7 min). Do NOT work around a timeout with `--no-verify` — that
329
+ bypasses the quality gate and is on the standing deny list (R010).
330
+ Note: git worktrees run typecheck only (`.husky/pre-commit` lines 7-12 branch on
331
+ `[ -f .git ]` and exit 0), so the long budget matters most on the MAIN worktree.
300
332
  6. On success: remove in-progress, add verify-ready
301
333
  7. On failure: remove in-progress, add needs-review, comment error summary
302
334
 
@@ -425,6 +457,9 @@ steps:
425
457
  ⚠ do NOT add Closes/Fixes/Resolves keywords to this commit message (#1542) — this commit merges into
426
458
  develop later via the release PR; a close keyword here bypasses the PR-body mechanism auto-tag.yml
427
459
  relies on (see step 3.b below). Use `Refs #N` if a cross-reference is needed.
460
+ ⚠ Bash timeout (#1645): delegate this commit with an explicit `timeout: 400000` — the
461
+ main-worktree pre-commit hook runs the full test suite (~165s) and the Bash default of
462
+ 120000ms kills it with exit 143. `--no-verify` is NOT an acceptable workaround (R010).
428
463
  h. mgr-gitnerd push release/v{NEW} to origin — NEVER push this commit to develop directly. Pushing to
429
464
  develop here reproduces the diff=0 PR failure this reordering fixes (#1542).
430
465
  i. mandatory verification (with existence guard for partial-update safety), run on release/v{NEW}:
@@ -1,6 +1,6 @@
1
1
  {
2
- "version": "1.1.58",
3
- "lastUpdated": "2026-09-02T00:00:00.000Z",
2
+ "version": "1.1.59",
3
+ "lastUpdated": "2026-09-03",
4
4
  "omcustomMinClaudeCode": "2.1.121",
5
5
  "omcustomMinClaudeCodeReason": "Sensitive-path direct Write/Edit on .claude/** under bypassPermissions (R010 deprecation, #1101)",
6
6
  "components": [
@@ -54,6 +54,30 @@ steps:
54
54
  "[pre-triage] WARNING: Issue #N references vX.Y.Z (not in git tags) — body may be stale"
55
55
  - Output all warnings as advisory log; do NOT halt
56
56
 
57
+ Phase 0.5 — Measure the EFFECTIVE permission mode (advisory, do NOT halt).
58
+
59
+ Why: CC v2.1.257 stopped honoring `permissions.defaultMode` declared in PROJECT scope
60
+ (`.claude/settings.json` / `.claude/settings.local.json`). Only user/managed scope or an
61
+ explicit `--permission-mode` flag takes effect. R010 「Universal bypassPermissions」 assumes
62
+ the parent session runs unattended under bypassPermissions; if that assumption is silently
63
+ false, this pipeline stalls on a permission prompt mid-run with no diagnostic (#1644).
64
+
65
+ 1. Read the user-scope setting (project scope is NOT authoritative on v2.1.257+):
66
+ user_mode=$(jq -r '.permissions.defaultMode // "unset"' ~/.claude/settings.json 2>/dev/null || echo "unset")
67
+
68
+ 2. The `--permission-mode` launch flag cannot be read from inside the session. Treat it as
69
+ UNKNOWN — never infer that it was passed.
70
+
71
+ 3. Report and, when not bypassPermissions, warn:
72
+ - user_mode == "bypassPermissions":
73
+ report: "[pre-triage] effective permission mode: bypassPermissions (user scope)"
74
+ - otherwise:
75
+ stderr warning: "[pre-triage] WARNING: effective permission mode is <user_mode>; unattended run may prompt. Project-scope permissions.defaultMode is IGNORED on CC v2.1.257+ (#1644). To run unattended, launch with --permission-mode bypassPermissions or set it in user-scope ~/.claude/settings.json."
76
+ - Do NOT halt (advisory only — a prompted run still completes with a human present).
77
+
78
+ 4. Do NOT read, echo, or modify any credential material while checking settings — read the
79
+ single `permissions.defaultMode` field only (R001).
80
+
57
81
  Phase 1 — Ensure required labels exist, then scan issues.
58
82
 
59
83
  1. Create labels if missing (idempotent):
@@ -297,6 +321,14 @@ steps:
297
321
  develop-bound commit auto-closes the issue on push — BEFORE release/tag/publish (observed v1.1.38,
298
322
  07:49:26Z). Close keywords belong ONLY in the release-stage PR body (see release step 3.b) — auto-tag.yml
299
323
  greps the PR body, not commit messages, to decide which issues to close.
324
+ ⚠ Bash timeout (#1645): the main-worktree `.husky/pre-commit` runs typecheck + lint +
325
+ the FULL `bun test --coverage` suite (~165s measured) before the commit lands. The Bash
326
+ tool's default timeout is 120000ms, so a `git commit` delegation with the default budget
327
+ is killed mid-hook with exit 143 (SIGTERM). Delegate `git commit` with an explicit
328
+ `timeout: 400000` (≈6.7 min). Do NOT work around a timeout with `--no-verify` — that
329
+ bypasses the quality gate and is on the standing deny list (R010).
330
+ Note: git worktrees run typecheck only (`.husky/pre-commit` lines 7-12 branch on
331
+ `[ -f .git ]` and exit 0), so the long budget matters most on the MAIN worktree.
300
332
  6. On success: remove in-progress, add verify-ready
301
333
  7. On failure: remove in-progress, add needs-review, comment error summary
302
334
 
@@ -425,6 +457,9 @@ steps:
425
457
  ⚠ do NOT add Closes/Fixes/Resolves keywords to this commit message (#1542) — this commit merges into
426
458
  develop later via the release PR; a close keyword here bypasses the PR-body mechanism auto-tag.yml
427
459
  relies on (see step 3.b below). Use `Refs #N` if a cross-reference is needed.
460
+ ⚠ Bash timeout (#1645): delegate this commit with an explicit `timeout: 400000` — the
461
+ main-worktree pre-commit hook runs the full test suite (~165s) and the Bash default of
462
+ 120000ms kills it with exit 143. `--no-verify` is NOT an acceptable workaround (R010).
428
463
  h. mgr-gitnerd push release/v{NEW} to origin — NEVER push this commit to develop directly. Pushing to
429
464
  develop here reproduces the diff=0 PR failure this reordering fixes (#1542).
430
465
  i. mandatory verification (with existence guard for partial-update safety), run on release/v{NEW}: