@feigi/fleet-ctl 3.36.0 → 3.36.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feigi/fleet-ctl",
3
- "version": "3.36.0",
3
+ "version": "3.36.1",
4
4
  "description": "Agent fleet: run-team controller, merge bot, PR reviewer, and the ticket pipeline they share",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -368,16 +368,25 @@ esac
368
368
  # `tests 0` and exits 0. The suite moved and the Recipe did not, so it is
369
369
  # stale, refused like a binary that is gone. Tracked, not present on disk: a
370
370
  # fresh worktree holds only what is tracked. Only a word the shell globs as
371
- # written, from <repo>, can be settled without running the command. A word
372
- # carrying quoting or an expansion is accepted unprobed, whole, since an
373
- # operator in it may be quoted; any other word is split at each `;`, `&`, `|`,
374
- # `(` and `)`, operators to the shell whether or not whitespace surrounds
375
- # them, and each piece is judged as a word of its own. An option, an `=`
371
+ # written, from <repo>, can be settled without running the command. The scan
372
+ # reads the whole command one character at a time under one rule: a region
373
+ # inside `'…'`, `"…"`, backticks, `$(…)` or `${…}`, or a `\`-escaped byte, is
374
+ # opaque, and makes the piece it belongs to quoted or expansion-bearing,
375
+ # accepted unprobed whole; so does a `{`, `}`, `~` or bare `$`. Inside a `$(…)`
376
+ # or a `${…}` the quotes and the substitutions are read as the shell reads
377
+ # them, so a quoted `)` or `}` closes nothing, and a `"…"` holds substitutions
378
+ # of its own. A backslash and a newline together are removed before the shell
379
+ # splits words, so they quote nothing and end nothing. An unquoted `;`, `&`,
380
+ # `|`, `(`, `)`, `<` or `>` is an operator to the shell whether or not
381
+ # whitespace surrounds it, and an unquoted blank ends a piece: each piece is
382
+ # judged as a word of its own. A quote, a backtick or a `$(` or `${` still open
383
+ # at the end of the command is refused: `sh -c` dies on it, so it is a Recipe
384
+ # that cannot run. An option, an `=`
376
385
  # assignment or value, a path outside <repo>, or the target of a `<` or `>`
377
386
  # redirection is the program's own to read, or selects no test, and is
378
- # accepted unprobed too. The scan stops at a `cd` or `pushd`, past which a
379
- # pattern no longer resolves from <repo>, and at a word that is not split but
380
- # ends in an operator then `cd` or `pushd`. A program's own directory option,
387
+ # accepted unprobed too. The scan stops judging at a `cd` or `pushd` piece,
388
+ # past which a pattern no longer resolves from <repo>.
389
+ # A program's own directory option,
381
390
  # such as `git -C`, does not stop it: whether that option moves where the
382
391
  # program resolves a pattern is the program's to say, so a Recipe must quote a
383
392
  # pattern that a program resolves under its own directory option, as in
@@ -428,71 +437,154 @@ if [ "$field" = test ]; then
428
437
  esac
429
438
  done; exit 1; }
430
439
  }
431
- set -f
432
- prev=
433
- # shellcheck disable=SC2086 # field splitting is the point: scanning every word
434
- for word in $value; do
435
- case $word in
436
- *[\'\"\\\$\`\{\}\~]*)
437
- case $word in *[\(\;\&\|]cd|*[\(\;\&\|]pushd) break ;; esac
438
- prev=$word
439
- continue ;;
440
+ # Judge one piece of the command: $1 is `P` (plain: the shell globs it as
441
+ # written) or `Q` (quoted or expansion-bearing: opaque), $2 the piece. Dies
442
+ # on a stale pattern; otherwise returns 0 having accepted the piece.
443
+ judge() {
444
+ [ -z "$stop" ] || return 0
445
+ piece=$2
446
+ was=$before
447
+ before=$piece
448
+ if [ -n "$redir" ]; then redir=; return 0; fi
449
+ [ "$1" = P ] || return 0
450
+ case $piece in
451
+ cd|pushd) stop=1; return 0 ;;
452
+ -*|*=*|/*|*..*) return 0 ;;
453
+ *'*'*|*'?'*|*'['*']'*) ;;
454
+ *) return 0 ;;
455
+ esac
456
+ case $was in
457
+ -*=*) ;;
458
+ -*) case $piece in */*|*.*) ;; *) return 0 ;; esac ;;
440
459
  esac
441
- before=$prev
442
- rest=$word
443
- first=1
460
+ # The second pathspec is the directories the piece matches: the shell
461
+ # hands `tests/*` the directory `tests/unit`, which ls-files lists only as
462
+ # the prefix of the files beneath it.
463
+ tracked=$(git -C "$repo" ls-files -- ":(glob)$piece" ":(glob)${piece%/}/**" 2>"$errf") || {
464
+ listed=$?
465
+ die "cannot list the files tracked in $where to check its test command's pattern '$piece' (git ls-files exit $listed): $(cat "$errf" 2>/dev/null)"
466
+ }
467
+ [ -z "$tracked" ] || return 0
468
+ lead=${piece%%[*?[]*}
444
469
  while :; do
445
- if [ -z "$first" ]; then
446
- case $rest in
447
- *[\;\&\|\(\)]*) rest=${rest#*[\;\&\|\(\)]} ;;
448
- *) break ;;
449
- esac
450
- before=
451
- fi
452
- first=
453
- piece=${rest%%[\;\&\|\(\)]*}
454
- follows=$prev
455
- prev=$piece
456
- case $follows in *[\<\>]) continue ;; esac
457
- case $piece in
458
- cd|pushd) break 2 ;;
459
- -*|*=*|/*|*..*|*[\<\>]*) continue ;;
460
- *'*'*|*'?'*|*'['*']'*) ;;
461
- *) continue ;;
462
- esac
463
- case $before in
464
- -*=*) ;;
465
- -*) case $piece in */*|*.*) ;; *) continue ;; esac ;;
466
- esac
467
- # The second pathspec is the directories the piece matches: the shell
468
- # hands `tests/*` the directory `tests/unit`, which ls-files lists only as
469
- # the prefix of the files beneath it.
470
- tracked=$(git -C "$repo" ls-files -- ":(glob)$piece" ":(glob)${piece%/}/**" 2>"$errf") || {
471
- listed=$?
472
- die "cannot list the files tracked in $where to check its test command's pattern '$piece' (git ls-files exit $listed): $(cat "$errf" 2>/dev/null)"
473
- }
474
- [ -z "$tracked" ] || continue
475
- lead=${piece%%[*?[]*}
476
- while :; do
477
- case $lead in */*) lead=${lead%/*} ;; *) break ;; esac
478
- opq=0
479
- opaque "$lead" || opq=$?
480
- case $opq in
481
- 0) continue 2 ;;
482
- 1) ;;
483
- *) die "cannot ask git whether '$lead' is a symlink or a submodule in $where, to check its test command's pattern '$piece' (git ls-files exit $listed): $(cat "$errf" 2>/dev/null)" ;;
484
- esac
485
- done
486
- ignored=0
487
- git -C "$repo" check-ignore -q --no-index -- "$piece" 2>"$errf" || ignored=$?
488
- case $ignored in
489
- 0) ;;
490
- 1) die "the Recipe cache at $cache is invalid: its test command's pattern '$piece' matches no file tracked in $where — a Test entrypoint that selects no tests passes having run nothing, so the Recipe is stale, not a finding; a pattern that a program resolves under its own directory option, such as git -C, must be quoted; $derive" ;;
491
- *) die "cannot ask git whether $repo ignores its test command's pattern '$piece' (git check-ignore exit $ignored): $(cat "$errf" 2>/dev/null)" ;;
470
+ case $lead in */*) lead=${lead%/*} ;; *) break ;; esac
471
+ opq=0
472
+ opaque "$lead" || opq=$?
473
+ case $opq in
474
+ 0) return 0 ;;
475
+ 1) ;;
476
+ *) die "cannot ask git whether '$lead' is a symlink or a submodule in $where, to check its test command's pattern '$piece' (git ls-files exit $listed): $(cat "$errf" 2>/dev/null)" ;;
492
477
  esac
493
478
  done
479
+ ignored=0
480
+ git -C "$repo" check-ignore -q --no-index -- "$piece" 2>"$errf" || ignored=$?
481
+ case $ignored in
482
+ 0) ;;
483
+ 1) die "the Recipe cache at $cache is invalid: its test command's pattern '$piece' matches no file tracked in $where — a Test entrypoint that selects no tests passes having run nothing, so the Recipe is stale, not a finding; a pattern that a program resolves under its own directory option, such as git -C, must be quoted; $derive" ;;
484
+ *) die "cannot ask git whether $repo ignores its test command's pattern '$piece' (git check-ignore exit $ignored): $(cat "$errf" 2>/dev/null)" ;;
485
+ esac
486
+ }
487
+ # End the piece being read, if there is one, and judge it.
488
+ flush() {
489
+ if [ -n "$scan_piece" ]; then judge "$scan_kind" "$scan_piece"; fi
490
+ scan_piece=
491
+ scan_kind=P
492
+ }
493
+ nl='
494
+ '
495
+ before=
496
+ redir=
497
+ stop=
498
+ scan_rest=$value
499
+ scan_piece=
500
+ scan_kind=P
501
+ scan_sq=
502
+ scan_ctx=
503
+ scan_top=
504
+ # The regions open around the scan point, innermost first: `"` a double
505
+ # quote, a backtick, `(` a `$(`, `{` a `${`. A single quote holds nothing
506
+ # inside it, so it is a flag, not a region.
507
+ scan_push() {
508
+ scan_ctx=$1$scan_ctx
509
+ scan_top=$1
510
+ }
511
+ scan_pop() {
512
+ scan_ctx=${scan_ctx#?}
513
+ scan_top=${scan_ctx%"${scan_ctx#?}"}
514
+ }
515
+ # After a `$` already read: a `(` or `{` right behind it opens a region.
516
+ scan_dollar() {
517
+ case $scan_rest in
518
+ '('*) scan_push '('; scan_piece=$scan_piece'('; scan_rest=${scan_rest#?} ;;
519
+ '{'*) scan_push '{'; scan_piece=$scan_piece'{'; scan_rest=${scan_rest#?} ;;
520
+ esac
521
+ }
522
+ while [ -n "$scan_rest" ]; do
523
+ scan_c=${scan_rest%"${scan_rest#?}"}
524
+ scan_rest=${scan_rest#?}
525
+ if [ -n "$scan_sq" ]; then
526
+ scan_piece=$scan_piece$scan_c
527
+ if [ "$scan_c" = "'" ]; then scan_sq=; fi
528
+ continue
529
+ fi
530
+ if [ "$scan_c" = '\' ]; then
531
+ scan_next=${scan_rest%"${scan_rest#?}"}
532
+ scan_rest=${scan_rest#?}
533
+ # A backslash and a newline are removed before the shell splits words:
534
+ # they quote nothing and end nothing.
535
+ if [ "$scan_next" = "$nl" ]; then continue; fi
536
+ scan_piece=$scan_piece$scan_c$scan_next
537
+ scan_kind=Q
538
+ continue
539
+ fi
540
+ case $scan_top in
541
+ '"')
542
+ scan_piece=$scan_piece$scan_c
543
+ case $scan_c in
544
+ '"') scan_pop ;;
545
+ '`') scan_push '`' ;;
546
+ '$') scan_dollar ;;
547
+ esac
548
+ continue ;;
549
+ '`')
550
+ scan_piece=$scan_piece$scan_c
551
+ if [ "$scan_c" = '`' ]; then scan_pop; fi
552
+ continue ;;
553
+ '('|'{')
554
+ scan_piece=$scan_piece$scan_c
555
+ case $scan_c in
556
+ "'") scan_sq=1 ;;
557
+ '"') scan_push '"' ;;
558
+ '`') scan_push '`' ;;
559
+ '$') scan_dollar ;;
560
+ '(') if [ "$scan_top" = '(' ]; then scan_push '('; fi ;;
561
+ ')') if [ "$scan_top" = '(' ]; then scan_pop; fi ;;
562
+ '{') if [ "$scan_top" = '{' ]; then scan_push '{'; fi ;;
563
+ '}') if [ "$scan_top" = '{' ]; then scan_pop; fi ;;
564
+ esac
565
+ continue ;;
566
+ esac
567
+ case $scan_c in
568
+ "'") scan_sq=1; scan_kind=Q; scan_piece=$scan_piece$scan_c ;;
569
+ '"') scan_push '"'; scan_kind=Q; scan_piece=$scan_piece$scan_c ;;
570
+ '`') scan_push '`'; scan_kind=Q; scan_piece=$scan_piece$scan_c ;;
571
+ '$')
572
+ scan_kind=Q
573
+ scan_piece=$scan_piece$scan_c
574
+ scan_dollar ;;
575
+ '{'|'}'|'~') scan_kind=Q; scan_piece=$scan_piece$scan_c ;;
576
+ ' '|' '|"$nl") flush ;;
577
+ ';'|'&'|'|'|'('|')'|'<'|'>')
578
+ flush
579
+ before=
580
+ case $scan_c in '<'|'>') redir=1 ;; esac ;;
581
+ *) scan_piece=$scan_piece$scan_c ;;
582
+ esac
494
583
  done
495
- set +f
584
+ flush
585
+ if [ -n "$scan_sq" ] || [ -n "$scan_ctx" ]; then
586
+ die "the Recipe cache at $cache is invalid: its test command leaves a quote, a backtick, a \$( or a \${ open, so sh cannot run it — a Recipe that cannot run is stale, not a finding; $derive"
587
+ fi
496
588
  fi
497
589
 
498
590
  printf '%s\n' "$value"