@zgeoff/chex 0.8.9 → 0.8.11

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": "@zgeoff/chex",
3
- "version": "0.8.9",
3
+ "version": "0.8.11",
4
4
  "description": "Run each shared docs and repo check as one subcommand, with the lefthook pre-push baseline that calls them",
5
5
  "keywords": [
6
6
  "checks",
@@ -79,17 +79,17 @@
79
79
  "typecheck": "tsrs --fast"
80
80
  },
81
81
  "dependencies": {
82
- "@zgeoff/std": "0.8.1",
82
+ "@zgeoff/std": "0.8.2",
83
83
  "oxc-parser": "0.160.0",
84
84
  "ts-pattern": "5.9.2",
85
85
  "yaml": "2.9.1"
86
86
  },
87
87
  "devDependencies": {
88
88
  "@types/bun": "1.4.4",
89
- "@zgeoff/oxlint-config": "0.15.4",
90
- "@zgeoff/rig": "0.3.10",
91
- "@zgeoff/std": "0.8.1",
92
- "@zgeoff/testing": "0.5.4",
89
+ "@zgeoff/oxlint-config": "0.15.5",
90
+ "@zgeoff/rig": "0.3.11",
91
+ "@zgeoff/std": "0.8.2",
92
+ "@zgeoff/testing": "0.5.5",
93
93
  "@zgeoff/tools-scripts": "0.0.0",
94
94
  "msw": "3.0.4",
95
95
  "tiny-invariant": "1.3.3",
@@ -2,6 +2,8 @@
2
2
  # Greps committed docs for prose violations; exits non-zero when any are found.
3
3
  # Violation greps fail the run; candidate greps print for judgment and never fail it.
4
4
  # Usage (from the repo root): check-prose.sh [<path>...]
5
+ # Outside a git work tree, it checks only the paths it is given, each under the current directory,
6
+ # and reads each one as changed.
5
7
  # With no path, it reads every README.md outside .claude/ and .agents/, every Markdown file under
6
8
  # docs/, every spike's results.md, and every skill's Markdown under .agents/skills/ and
7
9
  # .claude/skills/, where a consumer repo installs skills, under skills/, where zgeoff/skills keeps
@@ -10,11 +12,27 @@
10
12
  # shellcheck disable=SC2016
11
13
  set -uo pipefail
12
14
 
15
+ in_work_tree=1
13
16
  if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then
14
- echo "check-prose: run it inside a git work tree, because it lists the files with git" >&2
15
- exit 2
17
+ in_work_tree=0
18
+ # pr-body reads the pathspecs from the first `if [ "$#" -eq 0 ]` block, so this test is written apart.
19
+ if (($# == 0)); then
20
+ echo "check-prose: run it inside a git work tree, or name the files to check, because with no path it lists the files with git" >&2
21
+ exit 2
22
+ fi
16
23
  fi
17
24
 
25
+ # Prints the files the pathspecs name, each ending in a NUL. In a work tree it lists the tracked
26
+ # and untracked files git does not ignore; outside one, git grep --no-index lists each file with a
27
+ # line, so an empty file, which holds nothing to check, drops out.
28
+ list_files() {
29
+ if [ "$in_work_tree" -eq 1 ]; then
30
+ git ls-files -z --cached --others --exclude-standard -- "$@"
31
+ else
32
+ git grep --no-index -z -l -e '' -- "$@"
33
+ fi
34
+ }
35
+
18
36
  # A skill folder's README is a skill file, so only the READMEs outside the skill folders are listed
19
37
  # one by one.
20
38
  if [ "$#" -eq 0 ]; then
@@ -54,19 +72,29 @@ failure_marker=$(mktemp) || exit 2
54
72
  rm -f "$failure_marker"
55
73
  trap 'rm -f "$failure_marker"' EXIT
56
74
 
75
+ # Outside a work tree, git grep reads the named files with --no-index in place of --untracked.
76
+ grep_scope=--untracked
77
+ [ "$in_work_tree" -eq 1 ] || grep_scope=--no-index
78
+
57
79
  probe_status=0
58
- git grep -P -e x -- ':(exclude)*' > /dev/null 2>&1 || probe_status=$?
80
+ git grep "$grep_scope" -P -e x -- ':(exclude)*' > /dev/null 2>&1 || probe_status=$?
59
81
  if [ "$probe_status" -gt 1 ]; then
60
82
  echo "check-prose: git was built without PCRE support, so no doc was checked" >&2
61
83
  exit 2
62
84
  fi
63
85
 
64
86
  # The greps below read git's file list in pipelines, which drop git's exit status, so a git that
65
- # cannot list the files fails here once.
66
- if ! git ls-files --cached --others --exclude-standard -- "$@" > /dev/null; then
87
+ # cannot list the files fails here once. git grep exits 1 when it finds no file.
88
+ list_status=0
89
+ list_files "$@" > /dev/null || list_status=$?
90
+ if [ "$in_work_tree" -eq 1 ] && [ "$list_status" -ne 0 ]; then
67
91
  echo "check-prose: git ls-files failed, so no doc was checked" >&2
68
92
  exit 2
69
93
  fi
94
+ if [ "$in_work_tree" -eq 0 ] && [ "$list_status" -gt 1 ]; then
95
+ echo "check-prose: git could not read the paths; outside a git work tree, name files under the current directory, so no doc was checked" >&2
96
+ exit 2
97
+ fi
70
98
 
71
99
  # Every grep reads untracked files too, so a new doc is checked before it is staged, and skips
72
100
  # binary files.
@@ -75,7 +103,7 @@ fi
75
103
  # printing "clean".
76
104
  grep_docs() {
77
105
  local status=0
78
- git grep --untracked -I "$@" || status=$?
106
+ git grep "$grep_scope" -I "$@" || status=$?
79
107
  if [ "$status" -gt 1 ]; then
80
108
  echo "check-prose: git grep failed with status $status, so a check did not run" >&2
81
109
  : > "$failure_marker"
@@ -126,7 +154,7 @@ list_markdown() {
126
154
  if [[ $file == *.md && $file == "${markdown_dir:-}"* && -f $file ]]; then
127
155
  printf './%s\0' "$file"
128
156
  fi
129
- done < <(git ls-files -z --cached --others --exclude-standard -- "$@")
157
+ done < <(list_files "$@")
130
158
  }
131
159
 
132
160
  # Tracks fenced code blocks (backtick or tilde, any indent, closed by the same marker at least as
@@ -670,7 +698,7 @@ END { flush() }
670
698
  changed=$'\n'
671
699
  while IFS= read -r -d '' file; do
672
700
  changed+=$file$'\n'
673
- done < <(list_changed)
701
+ done < <(if [ "$in_work_tree" -eq 1 ]; then list_changed; else list_files "$@"; fi)
674
702
 
675
703
  # The Markdown files the paths name that the branch changes, each as ./<path> from list_markdown.
676
704
  paragraph_files=()
@@ -694,8 +722,11 @@ candidate "Paragraphs over $paragraph_warn words in a changed file (warning; rer
694
722
  candidate 'Candidates — filler words with term-of-art uses; cull the filler, keep the terms:' \
695
723
  "$(grep_docs -nPi '\b(naturally|cleanly|trivially|easy|simple|quick)\b' -- "$@")"
696
724
 
697
- candidate 'Candidates — speech verbs on data artifacts; the artifact holds, includes, returns, or matches:' \
698
- "$(grep_docs -nPi '(?<!file |table |column |export |bucket |method |variable |test )\b(names|says|tells|answers|knows|promises)\b(?! (rot|and locations|only))' -- "$@")"
725
+ # A thing that names is often the noun after another noun, as in "file names". "As the guide says"
726
+ # points the reader at another doc, so (*SKIP)(*F) drops it and the scan goes on after it. The
727
+ # pointer may wrap onto the next line, but never crosses a blank line or the end of a sentence.
728
+ candidate 'Candidates — speech verbs on data artifacts; make the thing the reader wants the subject, as in "The config is in the file":' \
729
+ "$(grep_docs -nPi '\bas(?:[ \t]|\n(?![ \t]*\n))+(?:(?:[^\s.]|\.(?=\S))+(?:[ \t]|\n(?![ \t]*\n))+){1,4}?says\b(*SKIP)(*F)|(?:(?<!file |table |column |export |bucket |method |variable |test )\bnames|\b(?:says|tells|answers|knows|promises))\b(?! (rot|and locations|only))' -- "$@")"
699
730
 
700
731
  candidate 'Candidates — delta-framing words; legal only when the baseline sits in the same doc:' \
701
732
  "$(grep_docs -nPi '(^|\. )(Also|Additionally|In addition),? |\b(already|today|before this work|as it does today)\b' -- "$@")"
@@ -94,8 +94,12 @@ function collectChecksFindings(
94
94
  },
95
95
  ];
96
96
 
97
+ // A main gate whose workflow-level group never cancels queues every run, so no job beside the
98
+ // release needs a cancelling group of its own: a newer run cancels nothing.
99
+ const isMainQueue = isMainGate(context) && isQueueGroup(workflowConcurrency);
100
+
97
101
  const jobFindings =
98
- deployJobs.length === 0
102
+ deployJobs.length === 0 || isMainQueue
99
103
  ? []
100
104
  : otherJobs
101
105
  .filter((job) => !isChecksGroup(context, findMember(job.definition, 'concurrency')))