@zgeoff/chex 0.3.12 → 0.3.13

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.
Files changed (55) hide show
  1. package/README.md +1 -0
  2. package/lefthook.yml +5 -5
  3. package/package.json +43 -1
  4. package/src/{read-branch-base.ts → branch/read-branch-base.ts} +1 -1
  5. package/src/{read-branch-files.ts → branch/read-branch-files.ts} +2 -2
  6. package/src/ci-plan/parse-docs-checks.ts +3 -3
  7. package/src/ci-plan/write-check-plan.ts +2 -2
  8. package/src/cli.ts +10 -10
  9. package/src/{read-range-commits.ts → commits/read-range-commits.ts} +1 -1
  10. package/src/{run-commits-check.ts → commits/run-commits-check.ts} +4 -4
  11. package/src/dependency-gates/parse-audit-ignore-ids.ts +1 -1
  12. package/src/dependency-gates/read-dependency-gate-findings.ts +1 -1
  13. package/src/dependency-gates/run-dependency-gates-check.ts +1 -1
  14. package/src/docs/check-prose.sh +74 -10
  15. package/src/docs/check-readmes.sh +12 -7
  16. package/src/docs/check-skill.sh +2 -1
  17. package/src/{build-init-plan.ts → init/build-init-plan.ts} +3 -3
  18. package/src/{pick-merge-blobs-command.ts → local-paths/pick-merge-blobs-command.ts} +1 -1
  19. package/src/{run-local-paths-check.ts → local-paths/run-local-paths-check.ts} +7 -7
  20. package/src/{read-pushed-ranges.ts → push/read-pushed-ranges.ts} +3 -3
  21. package/src/test-layout/collect-lane-suffixes.ts +1 -1
  22. package/src/{run-test-layout-check.ts → test-layout/run-test-layout-check.ts} +7 -7
  23. package/src/{parse-rig-lane-limits.ts → test-timeouts/parse-rig-lane-limits.ts} +1 -1
  24. package/src/{run-test-timeouts-check.ts → test-timeouts/run-test-timeouts-check.ts} +5 -5
  25. package/src/{run-uncommitted-check.ts → uncommitted/run-uncommitted-check.ts} +3 -3
  26. package/src/{collect-command-names.ts → workflows/collect-command-names.ts} +2 -2
  27. package/src/{read-checks-profile.ts → workflows/read-checks-profile.ts} +1 -1
  28. package/src/{run-workflows-check.ts → workflows/run-workflows-check.ts} +3 -3
  29. /package/src/{check-names.ts → cli/check-names.ts} +0 -0
  30. /package/src/{make-check-runner.ts → cli/make-check-runner.ts} +0 -0
  31. /package/src/{parse-chex-args.ts → cli/parse-chex-args.ts} +0 -0
  32. /package/src/{run-chex.ts → cli/run-chex.ts} +0 -0
  33. /package/src/{format-commit-lines.ts → commits/format-commit-lines.ts} +0 -0
  34. /package/src/{build-init-package.ts → init/build-init-package.ts} +0 -0
  35. /package/src/{run-init.ts → init/run-init.ts} +0 -0
  36. /package/src/{build-lefthook-extends.ts → lefthook/build-lefthook-extends.ts} +0 -0
  37. /package/src/{build-lefthook-guard.ts → lefthook/build-lefthook-guard.ts} +0 -0
  38. /package/src/{parse-lefthook-config.ts → lefthook/parse-lefthook-config.ts} +0 -0
  39. /package/src/{parse-added-lines.ts → local-paths/parse-added-lines.ts} +0 -0
  40. /package/src/{write-step-outputs.ts → output/write-step-outputs.ts} +0 -0
  41. /package/src/{write-text-file.ts → output/write-text-file.ts} +0 -0
  42. /package/src/{run-program.ts → program/run-program.ts} +0 -0
  43. /package/src/{parse-pushed-refs.ts → push/parse-pushed-refs.ts} +0 -0
  44. /package/src/{read-pushed-refs-input.ts → push/read-pushed-refs-input.ts} +0 -0
  45. /package/src/{parse-shell-words.ts → shell/parse-shell-words.ts} +0 -0
  46. /package/src/{shell-escape-parsers.ts → shell/shell-escape-parsers.ts} +0 -0
  47. /package/src/{parse-lane-limits.ts → test-timeouts/parse-lane-limits.ts} +0 -0
  48. /package/src/{make-file-probe.ts → uncommitted/make-file-probe.ts} +0 -0
  49. /package/src/{collect-concurrency-findings.ts → workflows/collect-concurrency-findings.ts} +0 -0
  50. /package/src/{collect-expression-references.ts → workflows/collect-expression-references.ts} +0 -0
  51. /package/src/{find-install-cache-path.ts → workflows/find-install-cache-path.ts} +0 -0
  52. /package/src/{find-member.ts → workflows/find-member.ts} +0 -0
  53. /package/src/{get-top-level-line.ts → workflows/get-top-level-line.ts} +0 -0
  54. /package/src/{pull-request-triggers.ts → workflows/pull-request-triggers.ts} +0 -0
  55. /package/src/{workflow-context.ts → workflows/workflow-context.ts} +0 -0
package/README.md CHANGED
@@ -71,6 +71,7 @@ commits since its base.
71
71
  Some docs checks skip files whether or not you name paths, and a path you name never brings a
72
72
  skipped file back:
73
73
 
74
+ - `prose` needs `perl` and a `git` with PCRE, and fails with exit 2 when it lacks one.
74
75
  - `prose` skips the `docs-writing`, `project-docs-writing`, `skill-writing` and `deslop` skills
75
76
  under `.agents/skills/`, `.claude/skills/`, `skills/` and `sync/skills/`, which hold the banned
76
77
  patterns as examples.
package/lefthook.yml CHANGED
@@ -50,7 +50,7 @@ pre-push:
50
50
  - name: chex-lint
51
51
  files:
52
52
  unset $(git rev-parse --local-env-vars); bun
53
- node_modules/@zgeoff/chex/src/read-branch-files.ts
53
+ node_modules/@zgeoff/chex/src/branch/read-branch-files.ts
54
54
  glob: '*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}'
55
55
  run:
56
56
  '{clear-git-env} bun x --no-install diet -- bun x --no-install oxlint
@@ -62,7 +62,7 @@ pre-push:
62
62
  - name: chex-shell
63
63
  files:
64
64
  unset $(git rev-parse --local-env-vars); bun
65
- node_modules/@zgeoff/chex/src/read-branch-files.ts
65
+ node_modules/@zgeoff/chex/src/branch/read-branch-files.ts
66
66
  glob: '*.sh'
67
67
  run: |
68
68
  {clear-git-env}
@@ -82,7 +82,7 @@ pre-push:
82
82
  - name: chex-docs
83
83
  files:
84
84
  unset $(git rev-parse --local-env-vars); bun
85
- node_modules/@zgeoff/chex/src/read-branch-files.ts
85
+ node_modules/@zgeoff/chex/src/branch/read-branch-files.ts
86
86
  glob: '*.md'
87
87
  run: '{clear-git-env} bun x --no-install diet -- bun run --silent check:docs'
88
88
  # GitHub runs no workflow from a subfolder of .github/workflows, and
@@ -94,7 +94,7 @@ pre-push:
94
94
  - name: chex-workflows
95
95
  files:
96
96
  unset $(git rev-parse --local-env-vars); bun
97
- node_modules/@zgeoff/chex/src/read-branch-files.ts
97
+ node_modules/@zgeoff/chex/src/branch/read-branch-files.ts
98
98
  glob:
99
99
  - '.github/workflows/*.{yml,yaml}'
100
100
  - 'sync/src/workflow-callers/*.{yml,yaml}'
@@ -142,6 +142,6 @@ pre-push:
142
142
  - name: chex-test
143
143
  files:
144
144
  unset $(git rev-parse --local-env-vars); bun
145
- node_modules/@zgeoff/chex/src/read-branch-files.ts
145
+ node_modules/@zgeoff/chex/src/branch/read-branch-files.ts
146
146
  glob: '*.{ts,tsx,toml}'
147
147
  run: '{clear-git-env} bun x --no-install diet -- bun x --no-install rig related {files}'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zgeoff/chex",
3
- "version": "0.3.12",
3
+ "version": "0.3.13",
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",
@@ -26,6 +26,48 @@
26
26
  "type": "module",
27
27
  "exports": {
28
28
  "./test-utils/*": "./src/test-utils/*.ts",
29
+ "./src/build-init-package.ts": "./src/init/build-init-package.ts",
30
+ "./src/build-init-plan.ts": "./src/init/build-init-plan.ts",
31
+ "./src/build-lefthook-extends.ts": "./src/lefthook/build-lefthook-extends.ts",
32
+ "./src/build-lefthook-guard.ts": "./src/lefthook/build-lefthook-guard.ts",
33
+ "./src/check-names.ts": "./src/cli/check-names.ts",
34
+ "./src/collect-command-names.ts": "./src/workflows/collect-command-names.ts",
35
+ "./src/collect-concurrency-findings.ts": "./src/workflows/collect-concurrency-findings.ts",
36
+ "./src/collect-expression-references.ts": "./src/workflows/collect-expression-references.ts",
37
+ "./src/find-install-cache-path.ts": "./src/workflows/find-install-cache-path.ts",
38
+ "./src/find-member.ts": "./src/workflows/find-member.ts",
39
+ "./src/format-commit-lines.ts": "./src/commits/format-commit-lines.ts",
40
+ "./src/get-top-level-line.ts": "./src/workflows/get-top-level-line.ts",
41
+ "./src/make-check-runner.ts": "./src/cli/make-check-runner.ts",
42
+ "./src/make-file-probe.ts": "./src/uncommitted/make-file-probe.ts",
43
+ "./src/parse-added-lines.ts": "./src/local-paths/parse-added-lines.ts",
44
+ "./src/parse-chex-args.ts": "./src/cli/parse-chex-args.ts",
45
+ "./src/parse-lane-limits.ts": "./src/test-timeouts/parse-lane-limits.ts",
46
+ "./src/parse-lefthook-config.ts": "./src/lefthook/parse-lefthook-config.ts",
47
+ "./src/parse-pushed-refs.ts": "./src/push/parse-pushed-refs.ts",
48
+ "./src/parse-rig-lane-limits.ts": "./src/test-timeouts/parse-rig-lane-limits.ts",
49
+ "./src/parse-shell-words.ts": "./src/shell/parse-shell-words.ts",
50
+ "./src/pick-merge-blobs-command.ts": "./src/local-paths/pick-merge-blobs-command.ts",
51
+ "./src/pull-request-triggers.ts": "./src/workflows/pull-request-triggers.ts",
52
+ "./src/read-branch-base.ts": "./src/branch/read-branch-base.ts",
53
+ "./src/read-branch-files.ts": "./src/branch/read-branch-files.ts",
54
+ "./src/read-checks-profile.ts": "./src/workflows/read-checks-profile.ts",
55
+ "./src/read-pushed-ranges.ts": "./src/push/read-pushed-ranges.ts",
56
+ "./src/read-pushed-refs-input.ts": "./src/push/read-pushed-refs-input.ts",
57
+ "./src/read-range-commits.ts": "./src/commits/read-range-commits.ts",
58
+ "./src/run-chex.ts": "./src/cli/run-chex.ts",
59
+ "./src/run-commits-check.ts": "./src/commits/run-commits-check.ts",
60
+ "./src/run-init.ts": "./src/init/run-init.ts",
61
+ "./src/run-local-paths-check.ts": "./src/local-paths/run-local-paths-check.ts",
62
+ "./src/run-program.ts": "./src/program/run-program.ts",
63
+ "./src/run-test-layout-check.ts": "./src/test-layout/run-test-layout-check.ts",
64
+ "./src/run-test-timeouts-check.ts": "./src/test-timeouts/run-test-timeouts-check.ts",
65
+ "./src/run-uncommitted-check.ts": "./src/uncommitted/run-uncommitted-check.ts",
66
+ "./src/run-workflows-check.ts": "./src/workflows/run-workflows-check.ts",
67
+ "./src/shell-escape-parsers.ts": "./src/shell/shell-escape-parsers.ts",
68
+ "./src/workflow-context.ts": "./src/workflows/workflow-context.ts",
69
+ "./src/write-step-outputs.ts": "./src/output/write-step-outputs.ts",
70
+ "./src/write-text-file.ts": "./src/output/write-text-file.ts",
29
71
  "./*": "./*"
30
72
  },
31
73
  "publishConfig": {
@@ -1,4 +1,4 @@
1
- import type { RunProgram } from './run-program.ts';
1
+ import type { RunProgram } from '../program/run-program.ts';
2
2
 
3
3
  export interface ReadBranchBaseOptions {
4
4
  readonly cwd: string;
@@ -1,6 +1,6 @@
1
+ import type { RunProgram } from '../program/run-program.ts';
2
+ import { runProgram } from '../program/run-program.ts';
1
3
  import { readBranchBase } from './read-branch-base.ts';
2
- import type { RunProgram } from './run-program.ts';
3
- import { runProgram } from './run-program.ts';
4
4
 
5
5
  interface ReadBranchFilesOptions {
6
6
  readonly cwd: string;
@@ -1,7 +1,7 @@
1
1
  import { match } from 'ts-pattern';
2
- import { docsCheckNames } from '../check-names.ts';
3
- import type { ChexRequest } from '../parse-chex-args.ts';
4
- import { parseChexArgs } from '../parse-chex-args.ts';
2
+ import { docsCheckNames } from '../cli/check-names.ts';
3
+ import type { ChexRequest } from '../cli/parse-chex-args.ts';
4
+ import { parseChexArgs } from '../cli/parse-chex-args.ts';
5
5
 
6
6
  export type DocsChecks =
7
7
  | { readonly kind: 'none' }
@@ -1,8 +1,8 @@
1
1
  import { appendFile, readFile } from 'node:fs/promises';
2
2
  import { join } from 'node:path';
3
3
  import { match } from 'ts-pattern';
4
- import type { StepOutputFile } from '../write-step-outputs.ts';
5
- import { writeStepOutputs } from '../write-step-outputs.ts';
4
+ import type { StepOutputFile } from '../output/write-step-outputs.ts';
5
+ import { writeStepOutputs } from '../output/write-step-outputs.ts';
6
6
  import { parseDocsChecks } from './parse-docs-checks.ts';
7
7
  import type { CheckPart, CheckPlan } from './plan-check-scripts.ts';
8
8
  import { planCheckScripts } from './plan-check-scripts.ts';
package/src/cli.ts CHANGED
@@ -3,17 +3,17 @@ import { rename, rm } from 'node:fs/promises';
3
3
  import { join } from 'node:path';
4
4
  import { readOptionalText } from '@zgeoff/std';
5
5
  import { runCIPlanCommand } from './ci-plan/write-check-plan.ts';
6
+ import { makeCheckRunner } from './cli/make-check-runner.ts';
7
+ import { runChex } from './cli/run-chex.ts';
8
+ import { runCommitsCommand } from './commits/run-commits-check.ts';
6
9
  import { runDependencyGatesCommand } from './dependency-gates/run-dependency-gates-check.ts';
7
- import { makeCheckRunner } from './make-check-runner.ts';
8
- import { runChex } from './run-chex.ts';
9
- import { runCommitsCommand } from './run-commits-check.ts';
10
- import { runInit } from './run-init.ts';
11
- import { runLocalPathsCommand } from './run-local-paths-check.ts';
12
- import { runTestLayoutCommand } from './run-test-layout-check.ts';
13
- import { runTestTimeoutsCommand } from './run-test-timeouts-check.ts';
14
- import { runUncommittedCommand } from './run-uncommitted-check.ts';
15
- import { runWorkflowsCommand } from './run-workflows-check.ts';
16
- import { writeTextFile } from './write-text-file.ts';
10
+ import { runInit } from './init/run-init.ts';
11
+ import { runLocalPathsCommand } from './local-paths/run-local-paths-check.ts';
12
+ import { writeTextFile } from './output/write-text-file.ts';
13
+ import { runTestLayoutCommand } from './test-layout/run-test-layout-check.ts';
14
+ import { runTestTimeoutsCommand } from './test-timeouts/run-test-timeouts-check.ts';
15
+ import { runUncommittedCommand } from './uncommitted/run-uncommitted-check.ts';
16
+ import { runWorkflowsCommand } from './workflows/run-workflows-check.ts';
17
17
 
18
18
  process.exitCode = await runChex(process.argv.slice(2), {
19
19
  runCheck: makeCheckRunner({
@@ -1,4 +1,4 @@
1
- import type { RunProgram } from './run-program.ts';
1
+ import type { RunProgram } from '../program/run-program.ts';
2
2
 
3
3
  // The revisions of one `git rev-list` call, such as `['<local sha>', '^origin/main']`.
4
4
  export type CommitRange = readonly string[];
@@ -1,11 +1,11 @@
1
1
  import { dirname, join } from 'node:path';
2
+ import type { ProgramResult, RunProgram } from '../program/run-program.ts';
3
+ import { runProgram } from '../program/run-program.ts';
4
+ import { readPushedRanges } from '../push/read-pushed-ranges.ts';
5
+ import { readPushedRefsInput } from '../push/read-pushed-refs-input.ts';
2
6
  import { formatCommitLines } from './format-commit-lines.ts';
3
- import { readPushedRanges } from './read-pushed-ranges.ts';
4
- import { readPushedRefsInput } from './read-pushed-refs-input.ts';
5
7
  import type { CommitRange } from './read-range-commits.ts';
6
8
  import { readRangeCommits } from './read-range-commits.ts';
7
- import type { ProgramResult, RunProgram } from './run-program.ts';
8
- import { runProgram } from './run-program.ts';
9
9
 
10
10
  export interface CommitsCheckOptions {
11
11
  readonly cwd: string;
@@ -1,4 +1,4 @@
1
- import { parseShellWords } from '../parse-shell-words.ts';
1
+ import { parseShellWords } from '../shell/parse-shell-words.ts';
2
2
 
3
3
  export function parseAuditIgnoreIDs(auditScript: string): string[] {
4
4
  const words = parseShellWords(auditScript).map((word) => word.text);
@@ -1,4 +1,4 @@
1
- import type { RunProgram } from '../run-program.ts';
1
+ import type { RunProgram } from '../program/run-program.ts';
2
2
  import { collectMissingFirstPartyExcludes } from './collect-missing-first-party-excludes.ts';
3
3
  import { collectStaleAgeGateExcludes } from './collect-stale-age-gate-excludes.ts';
4
4
  import { collectUnneededAuditIgnores } from './collect-unneeded-audit-ignores.ts';
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { runProgram } from '../run-program.ts';
3
+ import { runProgram } from '../program/run-program.ts';
4
4
  import type { DependencyGateSources } from './read-dependency-gate-findings.ts';
5
5
  import { readDependencyGateFindings } from './read-dependency-gate-findings.ts';
6
6
 
@@ -45,6 +45,22 @@ for root in .agents/skills .claude/skills skills sync/skills; do
45
45
  done
46
46
  set -- "$@" ':(exclude,attr:linguist-vendored)' ':(exclude,attr:linguist-vendored=true)'
47
47
 
48
+ if ! perl -e 1 > /dev/null 2>&1; then
49
+ echo "check-prose: perl is required and was not found on the PATH, so no doc was checked" >&2
50
+ exit 2
51
+ fi
52
+
53
+ failure_marker=$(mktemp) || exit 2
54
+ rm -f "$failure_marker"
55
+ trap 'rm -f "$failure_marker"' EXIT
56
+
57
+ probe_status=0
58
+ git grep -P -e x -- ':(exclude)*' > /dev/null 2>&1 || probe_status=$?
59
+ if [ "$probe_status" -gt 1 ]; then
60
+ echo "check-prose: git was built without PCRE support, so no doc was checked" >&2
61
+ exit 2
62
+ fi
63
+
48
64
  # The greps below read git's file list in pipelines, which drop git's exit status, so a git that
49
65
  # cannot list the files fails here once.
50
66
  if ! git ls-files --cached --others --exclude-standard -- "$@" > /dev/null; then
@@ -54,8 +70,51 @@ fi
54
70
 
55
71
  # Every grep reads untracked files too, so a new doc is checked before it is staged, and skips
56
72
  # binary files.
73
+ # A git grep that fails for any reason but "no match" (status 1) writes the marker file, because the
74
+ # greps run in command substitutions that drop their status. The script then fails instead of
75
+ # printing "clean".
57
76
  grep_docs() {
58
- git grep --untracked -I "$@"
77
+ local status=0
78
+ git grep --untracked -I "$@" || status=$?
79
+ if [ "$status" -gt 1 ]; then
80
+ echo "check-prose: git grep failed with status $status, so a check did not run" >&2
81
+ : > "$failure_marker"
82
+ fi
83
+ return 0
84
+ }
85
+
86
+ # macOS awk dies on a line that is not valid UTF-8 under a UTF-8 locale, so awk runs byte-wise.
87
+ # A failed awk marks the run as incomplete, because the callers read it in command substitutions
88
+ # that drop its status.
89
+ run_awk() {
90
+ LC_ALL=C awk "$@" || : > "$failure_marker"
91
+ }
92
+
93
+ # Cuts byte-wise, for the same reason.
94
+ run_cut() {
95
+ LC_ALL=C cut "$@" || : > "$failure_marker"
96
+ }
97
+
98
+ # Runs awk over the NUL-separated paths on stdin.
99
+ xargs_awk() {
100
+ xargs -0 -r env LC_ALL=C awk "$@" || : > "$failure_marker"
101
+ }
102
+
103
+ # Prints the lines of stdin that match the Perl pattern $1 before the unit separator, ignoring case.
104
+ # perl stands in for grep -P, which BSD grep lacks. It matches the line and the pattern decoded as
105
+ # UTF-8, so word boundaries and case folding follow Unicode as GNU grep's do under a UTF-8 locale,
106
+ # and an invalid byte becomes U+FFFD, so the rest of the line still matches. It prints the original bytes.
107
+ grep_before_separator() {
108
+ CHECK_PROSE_PATTERN=$1 perl -MEncode -ne '
109
+ BEGIN {
110
+ my $pattern = $ENV{CHECK_PROSE_PATTERN};
111
+ utf8::decode($pattern);
112
+ $p = qr/^[^\x1f]*(?:$pattern)/iu;
113
+ }
114
+ my $line = $_;
115
+ $line = Encode::decode("UTF-8", $line, Encode::FB_DEFAULT);
116
+ print if $line =~ $p' ||
117
+ : > "$failure_marker"
59
118
  }
60
119
 
61
120
  # Prints the Markdown files the paths name, under the directory in $markdown_dir when it is set.
@@ -126,7 +185,7 @@ banned_words='\bsurfaces?\b|load-bearing|\bseams?\b|\bceilings?\b|(?<!code )\bfe
126
185
  report 'Banned words:' \
127
186
  "$(
128
187
  grep_docs -nPi "$banned_words" -- "$@" ':(exclude)*.md' ':(exclude)AGENTS.md' ':(exclude)agents'
129
- list_markdown "$@" ':(exclude)AGENTS.md' ':(exclude)agents' | xargs -0 -r awk "$fence_awk"'
188
+ list_markdown "$@" ':(exclude)AGENTS.md' ':(exclude)agents' | xargs_awk "$fence_awk"'
130
189
  # Replaces each code span with a space. As in CommonMark, a span closes at the next backtick run
131
190
  # as long as the one that opens it, and a run that nothing closes stays as text.
132
191
  function strip_spans(s, out, start, n, rest, r, off, closed) {
@@ -171,7 +230,7 @@ report 'Banned words:' \
171
230
  gsub(/\037/, "", text)
172
231
  text = strip_spans(text)
173
232
  print text "\037" file_name()":"FNR":"$0
174
- }' | grep -aPi "^[^\\x1f]*(?:$banned_words)" | cut -d $'\037' -f 2-
233
+ }' | grep_before_separator "$banned_words" | run_cut -d $'\037' -f 2-
175
234
  )"
176
235
 
177
236
  report 'Filler with no term-of-art use:' \
@@ -189,7 +248,7 @@ report '"Should succeed" in a procedure — state the expected outcome instead:'
189
248
  report 'Number joined to its unit ("64KB"; write "64 KB"; code blocks are exempt):' \
190
249
  "$(
191
250
  grep_docs -nP '\b[0-9]+(KB|MB|GB|TB|KiB|MiB|GiB|ms)\b' -- "$@" ':(exclude)*.md'
192
- list_markdown "$@" | xargs -0 -r awk "$fence_awk"'
251
+ list_markdown "$@" | xargs_awk "$fence_awk"'
193
252
  {
194
253
  m = fence_marker($0)
195
254
  if (m != "") {
@@ -206,7 +265,7 @@ report 'Number joined to its unit ("64KB"; write "64 KB"; code blocks are exempt
206
265
  # reader types may hold a value. A bare s, d or h joined to its number is no unit here ("1990s",
207
266
  # "2d"); its spaced form is.
208
267
  report 'Values with units under docs/architecture (the code owns its values; code blocks are exempt):' \
209
- "$(markdown_dir=docs/architecture/ list_markdown "$@" | xargs -0 -r awk "$fence_awk"'
268
+ "$(markdown_dir=docs/architecture/ list_markdown "$@" | xargs_awk "$fence_awk"'
210
269
  {
211
270
  m = fence_marker($0)
212
271
  if (m != "") {
@@ -224,11 +283,11 @@ report 'Values with units under docs/architecture (the code owns its values; cod
224
283
  }')"
225
284
 
226
285
  report 'Horizontal rules outside YAML frontmatter:' \
227
- "$(list_markdown "$@" | xargs -0 -r awk \
286
+ "$(list_markdown "$@" | xargs_awk \
228
287
  'FNR==1{fm=($0=="---")} fm&&FNR>1&&$0=="---"{fm=0;next} !fm&&$0=="---"{print substr(FILENAME, 3)": "FNR}')"
229
288
 
230
289
  report 'Untagged code fences:' \
231
- "$(list_markdown "$@" | xargs -0 -r awk "$fence_awk"'
290
+ "$(list_markdown "$@" | xargs_awk "$fence_awk"'
232
291
  {
233
292
  m = fence_marker($0)
234
293
  if (m == "") next
@@ -623,14 +682,14 @@ done < <(list_markdown "$@")
623
682
 
624
683
  paragraphs=
625
684
  if [ "${#paragraph_files[@]}" -gt 0 ]; then
626
- paragraphs=$(awk -v warn="$paragraph_warn" "$fence_awk$paragraph_awk" "${paragraph_files[@]}")
685
+ paragraphs=$(run_awk -v warn="$paragraph_warn" "$fence_awk$paragraph_awk" "${paragraph_files[@]}")
627
686
  fi
628
687
 
629
688
  report "Paragraphs over $paragraph_fail words in a changed file (split each one; lists, tables and code blocks are exempt):" \
630
- "$(awk -F: -v limit="$paragraph_fail" '$NF > limit { print $0" words" }' <<< "$paragraphs")"
689
+ "$(run_awk -F: -v limit="$paragraph_fail" '$NF > limit { print $0" words" }' <<< "$paragraphs")"
631
690
 
632
691
  candidate "Paragraphs over $paragraph_warn words in a changed file (warning; reread each one and split it where it defends a decision):" \
633
- "$(awk -F: -v limit="$paragraph_fail" '$NF != "" && $NF <= limit { print $0" words" }' <<< "$paragraphs")"
692
+ "$(run_awk -F: -v limit="$paragraph_fail" '$NF != "" && $NF <= limit { print $0" words" }' <<< "$paragraphs")"
634
693
 
635
694
  candidate 'Candidates — filler words with term-of-art uses; cull the filler, keep the terms:' \
636
695
  "$(grep_docs -nPi '\b(naturally|cleanly|trivially|easy|simple|quick)\b' -- "$@")"
@@ -650,6 +709,11 @@ candidate 'Candidates — sentence-initial "A x is a" definitions; keep one only
650
709
  candidate 'Candidates — contrast frames, counted lists and stock openers; state the move, name the items, open with the job:' \
651
710
  "$(grep_docs -nPi ', not (a|an|the|its|their|from|for|to|in|on|by|only|just)\b|\brather than\b|\bis not the (job|point)\b|\b(two|three|four|five) (ways|traps|mistakes|things|rules)\b|^(This|The) skill (is|helps|lets|explains|finds|builds|shows)\b' -- "$@")"
652
711
 
712
+ if [ -e "$failure_marker" ]; then
713
+ echo "check-prose: a check failed to run, so the result above is incomplete" >&2
714
+ exit 2
715
+ fi
716
+
653
717
  if [ "$fail" -eq 0 ]; then
654
718
  echo 'check-prose: clean (candidates above, if any, need judgment only)'
655
719
  fi
@@ -38,10 +38,15 @@ while IFS= read -r file; do
38
38
  [ -f "$file" ] && readmes+=("$file")
39
39
  done < <(sort -u <<< "$listing")
40
40
 
41
- declare -A listed=()
42
- for readme in "${readmes[@]}"; do
43
- listed[$readme]=1
44
- done
41
+ # bash 3.2 has no associative arrays, so membership scans the list. An empty array is unbound under
42
+ # set -u in bash 3.2, so each expansion of it is guarded.
43
+ is_listed() {
44
+ local readme
45
+ for readme in ${readmes[@]+"${readmes[@]}"}; do
46
+ [ "$readme" = "$1" ] && return 0
47
+ done
48
+ return 1
49
+ }
45
50
 
46
51
  # Holds when the first H1 outside a code block starts "Spike: ".
47
52
  is_spike() {
@@ -63,7 +68,7 @@ is_spike() {
63
68
  # Holds when a README in one of the folder's direct subfolders is a spike README.
64
69
  indexes_spikes() {
65
70
  local dir=$1 readme
66
- for readme in "${readmes[@]}"; do
71
+ for readme in ${readmes[@]+"${readmes[@]}"}; do
67
72
  if [[ $readme == "$dir"/*/README.md && $readme != "$dir"/*/*/README.md ]] && is_spike "$readme"; then
68
73
  return 0
69
74
  fi
@@ -76,7 +81,7 @@ is_design() {
76
81
  [[ $readme == docs/design/*/README.md && /$readme/ != */spikes/* ]] || return 1
77
82
  [[ $readme != docs/design/*/*/README.md ]] && return 0
78
83
  parent=$(dirname "$(dirname "$readme")")/README.md
79
- [ -n "${listed[$parent]:-}" ] && is_design "$parent"
84
+ is_listed "$parent" && is_design "$parent"
80
85
  }
81
86
 
82
87
  manifests=(package.json go.mod Cargo.toml build.gradle.kts build.gradle settings.gradle.kts settings.gradle)
@@ -96,7 +101,7 @@ is_known() {
96
101
  }
97
102
 
98
103
  unknown=0
99
- for readme in "${readmes[@]}"; do
104
+ for readme in ${readmes[@]+"${readmes[@]}"}; do
100
105
  if ! is_known "$readme"; then
101
106
  unknown=$((unknown + 1))
102
107
  echo "$readme: not one of the five kinds of README; move its content into docs/, or into a code comment beside the code it explains"
@@ -61,7 +61,8 @@ fi
61
61
 
62
62
  checked=()
63
63
 
64
- for dir in "${dirs[@]}"; do
64
+ # An empty array is unbound under set -u in bash 3.2, so the expansion is guarded.
65
+ for dir in ${dirs[@]+"${dirs[@]}"}; do
65
66
  is_vendored "$dir" || checked+=("$dir")
66
67
  done
67
68
 
@@ -1,9 +1,9 @@
1
1
  import { match } from 'ts-pattern';
2
+ import type { LefthookOutcome } from '../lefthook/build-lefthook-extends.ts';
3
+ import { baselinePath, buildLefthookExtends } from '../lefthook/build-lefthook-extends.ts';
4
+ import { buildLefthookGuard, guardName, guardedHooks } from '../lefthook/build-lefthook-guard.ts';
2
5
  import type { PackageOutcome } from './build-init-package.ts';
3
6
  import { buildInitPackage, docsScript } from './build-init-package.ts';
4
- import type { LefthookOutcome } from './build-lefthook-extends.ts';
5
- import { baselinePath, buildLefthookExtends } from './build-lefthook-extends.ts';
6
- import { buildLefthookGuard, guardName, guardedHooks } from './build-lefthook-guard.ts';
7
7
 
8
8
  export interface InitWrite {
9
9
  readonly file: 'lefthook.yml' | 'package.json';
@@ -1,4 +1,4 @@
1
- import { formatCommitLines } from './format-commit-lines.ts';
1
+ import { formatCommitLines } from '../commits/format-commit-lines.ts';
2
2
 
3
3
  export interface MergeBlobsReadings {
4
4
  readonly commits: readonly string[];
@@ -1,14 +1,14 @@
1
1
  import { hostname } from 'node:os';
2
- import { formatCommitLines } from './format-commit-lines.ts';
2
+ import { formatCommitLines } from '../commits/format-commit-lines.ts';
3
+ import type { CommitRange } from '../commits/read-range-commits.ts';
4
+ import { readRangeCommits } from '../commits/read-range-commits.ts';
5
+ import type { RunProgram } from '../program/run-program.ts';
6
+ import { runProgram } from '../program/run-program.ts';
7
+ import { readPushedRanges } from '../push/read-pushed-ranges.ts';
8
+ import { readPushedRefsInput } from '../push/read-pushed-refs-input.ts';
3
9
  import { parseAddedLines } from './parse-added-lines.ts';
4
10
  import type { MergeBlobsReadings } from './pick-merge-blobs-command.ts';
5
11
  import { pickMergeBlobsCommand } from './pick-merge-blobs-command.ts';
6
- import { readPushedRanges } from './read-pushed-ranges.ts';
7
- import { readPushedRefsInput } from './read-pushed-refs-input.ts';
8
- import type { CommitRange } from './read-range-commits.ts';
9
- import { readRangeCommits } from './read-range-commits.ts';
10
- import type { RunProgram } from './run-program.ts';
11
- import { runProgram } from './run-program.ts';
12
12
 
13
13
  export interface LocalPathsCheckOptions {
14
14
  readonly cwd: string;
@@ -1,7 +1,7 @@
1
+ import type { ReadBranchBaseOptions } from '../branch/read-branch-base.ts';
2
+ import { readBranchBase, readDefaultBranch } from '../branch/read-branch-base.ts';
3
+ import type { CommitRange } from '../commits/read-range-commits.ts';
1
4
  import { parsePushedRefs } from './parse-pushed-refs.ts';
2
- import type { ReadBranchBaseOptions } from './read-branch-base.ts';
3
- import { readBranchBase, readDefaultBranch } from './read-branch-base.ts';
4
- import type { CommitRange } from './read-range-commits.ts';
5
5
 
6
6
  export interface PushedRangesOptions extends ReadBranchBaseOptions {
7
7
  // The lines git hands a pre-push hook on stdin, or null outside a push.
@@ -1,4 +1,4 @@
1
- import { parseLaneLimits } from '../parse-lane-limits.ts';
1
+ import { parseLaneLimits } from '../test-timeouts/parse-lane-limits.ts';
2
2
 
3
3
  // The suffixes that a test file name may carry before `.test.ts`. A lane of the resolved
4
4
  // rig.config.ts has exactly the suffix it gives, and a lane only the oxlint config names has
@@ -1,11 +1,11 @@
1
1
  import { join } from 'node:path';
2
- import { runProgram } from './run-program.ts';
3
- import { collectLaneSuffixes } from './test-layout/collect-lane-suffixes.ts';
4
- import { collectTestLayoutFaults } from './test-layout/collect-test-layout-faults.ts';
5
- import { collectWorkspaceRoots } from './test-layout/collect-workspace-roots.ts';
6
- import type { OxcParserModule } from './test-layout/oxc-parser-module.ts';
7
- import { parseWorkspacePatterns } from './test-layout/parse-workspace-patterns.ts';
8
- import { readOxcParser } from './test-layout/read-oxc-parser.ts';
2
+ import { runProgram } from '../program/run-program.ts';
3
+ import { collectLaneSuffixes } from './collect-lane-suffixes.ts';
4
+ import { collectTestLayoutFaults } from './collect-test-layout-faults.ts';
5
+ import { collectWorkspaceRoots } from './collect-workspace-roots.ts';
6
+ import type { OxcParserModule } from './oxc-parser-module.ts';
7
+ import { parseWorkspacePatterns } from './parse-workspace-patterns.ts';
8
+ import { readOxcParser } from './read-oxc-parser.ts';
9
9
 
10
10
  export interface TestLayoutCheckOptions {
11
11
  readonly readTrackedPaths: () => Promise<readonly string[]>;
@@ -1,4 +1,4 @@
1
- import { findMember } from './find-member.ts';
1
+ import { findMember } from '../workflows/find-member.ts';
2
2
 
3
3
  export type ParsedRigLaneLimits =
4
4
  | { readonly kind: 'parsed'; readonly limits: ReadonlyMap<string, number> }
@@ -1,11 +1,11 @@
1
1
  import { basename, dirname, join, posix } from 'node:path';
2
- import { findMember } from './find-member.ts';
2
+ import type { RunProgram } from '../program/run-program.ts';
3
+ import { runProgram } from '../program/run-program.ts';
4
+ import type { ShellWord } from '../shell/parse-shell-words.ts';
5
+ import { parseShellWords } from '../shell/parse-shell-words.ts';
6
+ import { findMember } from '../workflows/find-member.ts';
3
7
  import { parseLaneLimits } from './parse-lane-limits.ts';
4
8
  import { parseRigLaneLimits } from './parse-rig-lane-limits.ts';
5
- import type { ShellWord } from './parse-shell-words.ts';
6
- import { parseShellWords } from './parse-shell-words.ts';
7
- import type { RunProgram } from './run-program.ts';
8
- import { runProgram } from './run-program.ts';
9
9
 
10
10
  export interface TestTimeoutsCheckOptions {
11
11
  readonly cwd: string;
@@ -1,8 +1,8 @@
1
1
  import { join } from 'node:path';
2
+ import { readBranchFiles } from '../branch/read-branch-files.ts';
3
+ import type { RunProgram } from '../program/run-program.ts';
4
+ import { runProgram } from '../program/run-program.ts';
2
5
  import { makeFileProbe } from './make-file-probe.ts';
3
- import { readBranchFiles } from './read-branch-files.ts';
4
- import type { RunProgram } from './run-program.ts';
5
- import { runProgram } from './run-program.ts';
6
6
 
7
7
  export interface UncommittedCheckOptions {
8
8
  readonly cwd: string;
@@ -1,5 +1,5 @@
1
- import type { ShellWord } from './parse-shell-words.ts';
2
- import { parseShellWords } from './parse-shell-words.ts';
1
+ import type { ShellWord } from '../shell/parse-shell-words.ts';
2
+ import { parseShellWords } from '../shell/parse-shell-words.ts';
3
3
 
4
4
  // Each command contributes the word the shell runs, after any NAME=value assignments, plus the
5
5
  // script that bash, sh or bun runs. A command outside the forms read here returns undefined, so the
@@ -1,4 +1,4 @@
1
- import type { RunProgram } from './run-program.ts';
1
+ import type { RunProgram } from '../program/run-program.ts';
2
2
 
3
3
  export type ChecksProfile = 'public' | 'private';
4
4
 
@@ -1,15 +1,15 @@
1
1
  import { parseArgs } from 'node:util';
2
+ import type { RunProgram } from '../program/run-program.ts';
3
+ import { runProgram } from '../program/run-program.ts';
4
+ import { parseShellWords } from '../shell/parse-shell-words.ts';
2
5
  import { collectCommandNames } from './collect-command-names.ts';
3
6
  import { collectConcurrencyFindings } from './collect-concurrency-findings.ts';
4
7
  import { findInstallCachePath } from './find-install-cache-path.ts';
5
8
  import { findMember } from './find-member.ts';
6
9
  import { getTopLevelLine } from './get-top-level-line.ts';
7
- import { parseShellWords } from './parse-shell-words.ts';
8
10
  import { pullRequestTriggers } from './pull-request-triggers.ts';
9
11
  import type { ChecksProfile } from './read-checks-profile.ts';
10
12
  import { readChecksProfile } from './read-checks-profile.ts';
11
- import type { RunProgram } from './run-program.ts';
12
- import { runProgram } from './run-program.ts';
13
13
  import type { Job, WorkflowContext, WorkflowFinding } from './workflow-context.ts';
14
14
 
15
15
  export type { WorkflowFinding } from './workflow-context.ts';
File without changes
File without changes
File without changes
File without changes