@ai-ecoverse/slicc-shared-web 2.2.3 → 2.3.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/README.md CHANGED
@@ -8,7 +8,7 @@ Configuration shared by SLICC's web repos ([slicc-bios](https://github.com/ai-ec
8
8
  | `.github/workflows/pipeline.yml` | The one reusable workflow, described [below](#pipeline): lint on every event; on pull requests and in the merge queue a staging deploy (if any) and sharded integration tests; on pull requests a Claude and a Codex review; on `main` a release | `jobs: { ci: { uses: ai-ecoverse/slicc-shared-web/.github/workflows/pipeline.yml@vX.Y.Z, secrets: inherit } }` |
9
9
  | `biome.json` | Formatter settings and slicc's strict linter: cognitive complexity ≤ 25, functions ≤ 150 lines, no unused variables or imports, no floating or misused promises, naming conventions, `import type`/`export type`. Test files under `test/` get slicc's test exemptions | `biome.json`: `{ "extends": ["@ai-ecoverse/slicc-shared-web/biome"] }` |
10
10
  | `tsconfig.json` | TypeScript base for Node's type stripping | `tsconfig.json`: `{ "extends": "@ai-ecoverse/slicc-shared-web/tsconfig.json", "include": ["src/**/*.ts"] }` |
11
- | `lefthook.yml` | Pre-commit hooks: Biome, typecheck, no comments, no unit tests in git, AGENTS.md, and diff coverage over [only the unit tests the change reaches](#which-unit-tests-a-commit-runs) | `lefthook.yml`: the [fail-closed snippet below](#hooks-that-fail-closed), and `prepare`: `slicc-install-hooks` ([one hooks directory per worktree](#one-hooks-directory-per-worktree)) |
11
+ | `lefthook.yml` | Pre-commit hooks: Biome, typecheck, no comments, no unit tests in git, AGENTS.md, and diff coverage over [only the unit tests the change reaches](#which-unit-tests-a-commit-runs) | `lefthook.yml`: the [fail-closed snippet below](#hooks-that-fail-closed), and `prepare`: `slicc-install-hooks` plus the committed `.githooks/` it writes ([one hooks directory per worktree](#one-hooks-directory-per-worktree)) |
12
12
  | `mcr.config.mjs` | Unit-test coverage for JS and TS sources (`.js`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`) in `src/` or the `slicc.unitSources` directories (TS types are stripped first), written to `coverage/unit/lcov.info`. Every source file is in it, tested or not, and paths are matched relative to the repo root, so a checkout under a dot-directory such as `~/.bb/` still reports untested files to diff coverage. With `SLICC_UNIT_TESTS` set, `node --test` runs only those files ([below](#which-unit-tests-a-commit-runs)) | `test:unit`: `mcr -c node_modules/@ai-ecoverse/slicc-shared-web/mcr.config.mjs node --test 'test/unit/**/*.test.mjs'` |
13
13
  | `bin/` | `slicc-lint` runs every check below plus Biome and, if the repo has one, `typecheck`. Every step prints its own `<step>: PASS …` line, and slicc-lint checks for it: a step that exits 0 without one fails the run with exit 70 (`slicc-lint: FAIL <step> (no PASS line from it)`), so a check that silently stops early can't pass. The last line, `slicc-lint: PASS`, comes only after every step has printed its PASS, and a gate can require it. `slicc-lint-comments` runs the [slicc no-comment checker](https://github.com/ai-ecoverse/slicc/tree/main/packages/dev-tools/no-comment) at a pinned commit, allowing AGENTS.md and [`# renovate:` annotations](#versions-pinned-in-workflow-files) in workflow and action files. `slicc-agents-md`, `slicc-no-unit-tests` and `slicc-diff-cover` complete the set, and `slicc-unit-cover` is the diff-coverage hook. `slicc-minidump <file.dmp>...` prints a crash dump's stack, described [below](#crash-dumps). `slicc-memory-peak` prints the job's [memory peak](#memory-peak). `slicc-install-hooks` installs the hooks into [this worktree's own directory](#one-hooks-directory-per-worktree) | `lint`: `slicc-lint`, and the hooks above |
14
14
  | `pnpmfile.mjs` | pnpm's counterpart to the Renovate preset: an `updateConfig` hook that adds `@ai-ecoverse/*` to `minimumReleaseAgeExclude`, so pnpm 12 doesn't hold back our own fresh releases (`ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION`) while third-party packages keep its age check | in a repo with a pnpm lockfile, as a [config dependency](https://pnpm.io/config-dependencies) in `pnpm-workspace.yaml`: `configDependencies: { '@ai-ecoverse/slicc-shared-web': X.Y.Z }` plus `pnpmfile: node_modules/.pnpm-config/@ai-ecoverse/slicc-shared-web/pnpmfile.mjs` |
@@ -60,7 +60,7 @@ jobs:
60
60
 
61
61
  **Lint** fails the run, and nothing after it starts.
62
62
 
63
- **Deploy** runs the `deploy` command with every secret the caller passes as an environment variable, except the pipeline's own `AWS_BEARER_TOKEN_BEDROCK`, `SLICC_ISSUES_TOKEN` and `github_token`. The command writes `url=<staging URL>` to `$GITHUB_OUTPUT`; the tests and the reviewers get it as `STAGING_URL`.
63
+ **Deploy** runs the `deploy` command with every secret the caller passes as an environment variable, except the pipeline's own `AWS_BEARER_TOKEN_BEDROCK`, `SLICC_ISSUES_TOKEN` and `github_token`. The command writes `url=<staging URL>` to `$GITHUB_OUTPUT`; the tests and the reviewers get it as `STAGING_URL`. With `deploy-secrets`, a newline- or space-separated list of secret names, only those of them are exported.
64
64
 
65
65
  **Integration tests** install Chrome for Testing with `slicc-cdp install-browser` (with `--with-deps` where the runner has root or passwordless sudo) (`--version` from the `chrome` input, stable without it), then split the files matching `test-glob` across `shards` jobs by their timings, with [split-tests-by-timings](https://github.com/marketplace/actions/split-tests-by-timings). The timings are the JUnit reports of the latest completed run of the same workflow; without one, the split is by count. Each shard runs the repo's own `test` command unchanged: `harness/shard.cjs`, preloaded through `NODE_OPTIONS`, makes the outermost `node --test` run only the shard's files that its own patterns match, writes `junit/<shard>.xml` next to the usual spec output, and then takes itself out of the environment, so a `node --test` that a test starts runs as it would without it. Files a `node --test` call would run that are not in `test-glob` (unit tests, say, whether in the same call or another) run on shard 0 only, so nothing is dropped; when `test-glob` matches nothing, shard 0 runs the command unchanged and the others run nothing. Each call keeps its own JUnit report (`junit/<shard>-<pid>.xml` for all but the last). Each shard uploads `coverage/`, `artifacts/` and `junit/` as `integration-<shard>`. `integration` passes only when every shard did, so it is the one check to require, under the caller's job name (`ci / integration`). A suite whose last step reads every test's artifacts, as this repo's `verify.mjs` does, sets `shards: 1`.
66
66
 
@@ -85,7 +85,7 @@ Each reviewer answers with `findings.json`, held to one JSON schema:
85
85
 
86
86
  **Post** is the only job that writes to GitHub. Per reviewer it sets the commit status `review / claude` or `review / codex` (`success` for `approved`, `failure` for `denied`, `error` without findings), keeps one comment with its latest verdict and summary on the pull request (edited on each run), posts each comment on its line (or, for a line outside the diff, as a pull request comment naming it) unless the same comment is already there, and opens each issue unless one with the same title is already open. An issue in another repo of the same org needs `SLICC_ISSUES_TOKEN`, a token that can open issues there; one outside the org is logged and skipped.
87
87
 
88
- **Release** runs `semantic-release` after lint, without any test: what reached `main` went through the merge queue.
88
+ **Release** runs `semantic-release` after lint, without any test: what reached `main` went through the merge queue. GitHub sometimes rejects a push right after the tag push with a bare `(failed)`, most often semantic-release's push of `refs/notes/semantic-release-vX.Y.Z`, so the step puts a small `git` wrapper first on `PATH`: it retries `git push` and `git fetch` up to five times, 5, 10, 15 and 20 seconds apart, and runs every other git command once, as well as semantic-release's `git fetch --unshallow`, which fails on the job's full clone by design before semantic-release falls back to a plain fetch. When the push still fails, semantic-release fails before it publishes.
89
89
 
90
90
  **Review** is the check that stands for the reviews. On a pull request that gets a review it passes when both reviewers' `findings.json` say `approved`. On one that doesn't (a Renovate pull request outside `review-renovate`) it passes when `integration` did. In the merge queue it always passes, since the pull request was reviewed already. Require it next to `ci / integration`, as `ci / review`.
91
91
 
@@ -113,6 +113,7 @@ Every pull request does, except Renovate's: one opened by `renovate[bot]` from a
113
113
  | `test-glob` | `test/integration/**/*.test.mjs` | the files to split; their paths can't contain spaces |
114
114
  | `shards` | `4` | below 1 counts as 1 |
115
115
  | `deploy` | none | a command that deploys to staging |
116
+ | `deploy-secrets` | all | newline- or space-separated secret names (any case) that `deploy` gets |
116
117
  | `review-browser` | `npm run --if-present review:browser` | |
117
118
  | `review-prompt` | none | |
118
119
  | `review-renovate` | none | globs of Renovate group slugs whose pull requests get a review |
@@ -189,7 +190,7 @@ A workflow gets the line from the composite action, as its last step:
189
190
 
190
191
  ## Hooks that fail closed
191
192
 
192
- Git hooks live in the repo's `.git/hooks/`, which every worktree shares, so a commit can run in a worktree where `npm install` never ran. A repo's `lefthook.yml` makes that commit fail instead of skip the hooks:
193
+ With plain `lefthook install`, git hooks live in the repo's `.git/hooks/`, which every worktree shares, so a commit can run in a worktree where `npm install` never ran ([`slicc-install-hooks`](#one-hooks-directory-per-worktree) fails that commit with its shim instead). A repo's `lefthook.yml` makes that commit fail instead of skip the hooks:
193
194
 
194
195
  ```yaml
195
196
  assert_lefthook_installed: true
@@ -206,15 +207,18 @@ pre-commit:
206
207
 
207
208
  ## One hooks directory per worktree
208
209
 
209
- Without it, every worktree of a repo shares `.git/hooks/` with the main clone, and each `lefthook install` repoints that one hook at its own worktree's lefthook, so a commit anywhere runs with whichever worktree installed last, until that worktree is deleted. A repo's `package.json` installs the hooks with:
210
+ Without it, every worktree of a repo shares `.git/hooks/` with the main clone, and each `lefthook install` repoints that one hook at its own worktree's lefthook, so a commit anywhere runs with whichever worktree installed last, until that worktree is deleted. A repo rolls it out in one PR: `package.json` installs the hooks with
210
211
 
211
212
  ```json
212
213
  "prepare": "slicc-install-hooks"
213
214
  ```
214
215
 
215
- - **What it does:** moves `core.bare` and `core.worktree` from the shared config into the main worktree's `config.worktree` (so worktrees of a bare repo stay work trees), turns on `extensions.worktreeConfig`, sets this worktree's own `core.hooksPath` (`git config --worktree`) to `worktree-hooks/` in its git directory (`.git/worktree-hooks/` in the main clone, `.git/worktrees/<name>/worktree-hooks/` in a linked worktree), then runs `lefthook install` there. Running it again changes nothing.
216
- - **Hooks are never shared:** each worktree's hook calls its own `node_modules` lefthook, whatever another worktree installs later, and removing a worktree removes only its own hooks. Once it has run, lefthook's own `postinstall` and later `lefthook install` runs follow the same `core.hooksPath`. The first `npm install` in a new worktree runs that `postinstall` before `prepare`, so it still writes the shared `.git/hooks/` once.
217
- - **A worktree that never ran it:** it still falls back to the shared `.git/hooks/`, which any new worktree can repoint and which fails closed as [above](#hooks-that-fail-closed), until `npm install` runs there.
216
+ and the PR commits the `.githooks/` directory that the first `npm install` writes.
217
+
218
+ - **What it does:** sets one shared, relative `core.hooksPath` of `.githooks` (`<dir>/.githooks` for a package in a subdirectory of the repo), runs `lefthook install --force` with its output pointed at this worktree's gitignored `node_modules/.git-hooks/`, and writes a shim into `.githooks/` for every hook lefthook installed that has none yet. It never overwrites an existing shim. Git resolves a relative `core.hooksPath` against the top of the worktree a commit runs in, so each worktree runs its own committed shim, and the shim runs that worktree's own `node_modules/.git-hooks/<hook>`. No `extensions.worktreeConfig`, no per-worktree config, and `core.bare` stays where it is, so worktrees of a bare repo work too. Running it again changes nothing.
219
+ - **Hooks are never shared:** whatever another worktree installs later, removing a worktree removes only its own hooks, and a moved checkout keeps working. Lefthook's own `postinstall` refuses the custom `core.hooksPath`, writes nothing and doesn't fail the install, and git never reads `.git/hooks/` once `core.hooksPath` is set, so `allowScripts` needs no entry for lefthook.
220
+ - **A worktree that never ran `npm install`** fails every commit with `pre-commit: run npm install`, since its shim finds no `node_modules/.git-hooks/pre-commit`.
221
+ - **Clones set up by the previous version** (2.1.1, 1.29.3), which set an absolute per-worktree `core.hooksPath` into a `worktree-hooks/` directory: it unsets that in the current worktree's `config.worktree`. It leaves `extensions.worktreeConfig` and the moved `core.bare` alone.
218
222
  - **Outside a git checkout** (a packed tarball, say) it does nothing and exits 0.
219
223
 
220
224
  ## Which unit tests a commit runs
@@ -1,14 +1,28 @@
1
1
  #!/bin/sh
2
2
  set -eu
3
- git rev-parse --git-dir >/dev/null 2>&1 || exit 0
4
- common="$(git rev-parse --path-format=absolute --git-common-dir)"
5
- for key in core.bare core.worktree; do
6
- if value=$(git config --file "$common/config" --get "$key"); then
7
- git config --file "$common/config.worktree" --get "$key" >/dev/null || git config --file "$common/config.worktree" "$key" "$value"
8
- git config --file "$common/config" --unset "$key"
9
- fi
3
+ [ "$(git rev-parse --is-inside-work-tree 2>/dev/null)" = true ] || exit 0
4
+ own="$(git rev-parse --path-format=absolute --git-dir)/config.worktree"
5
+ if [ -f "$own" ]; then
6
+ case "$(git config --file "$own" --get-all core.hooksPath || true)" in
7
+ *worktree-hooks*) git config --file "$own" --unset-all core.hooksPath ;;
8
+ esac
9
+ fi
10
+ git config core.hooksPath "$(git rev-parse --show-prefix).githooks"
11
+ n="${GIT_CONFIG_COUNT:-0}"
12
+ (
13
+ export "GIT_CONFIG_COUNT=$((n + 1))" "GIT_CONFIG_KEY_$n=core.hooksPath" "GIT_CONFIG_VALUE_$n=$(pwd -P)/node_modules/.git-hooks"
14
+ lefthook install --force "$@"
15
+ )
16
+ mkdir -p .githooks
17
+ for hook in node_modules/.git-hooks/*; do
18
+ name="${hook##*/}"
19
+ case "$name" in *.*) continue ;; esac
20
+ if [ ! -f "$hook" ] || [ -e ".githooks/$name" ]; then continue; fi
21
+ cat >".githooks/$name" <<'SHIM'
22
+ #!/bin/sh
23
+ hook="${0%/*}/../node_modules/.git-hooks/${0##*/}"
24
+ [ -x "$hook" ] || { echo "${0##*/}: run npm install" >&2; exit 1; }
25
+ exec "$hook" "$@"
26
+ SHIM
27
+ chmod +x ".githooks/$name"
10
28
  done
11
- hooks="$(git rev-parse --absolute-git-dir)/worktree-hooks"
12
- git config extensions.worktreeConfig true
13
- git config --worktree core.hooksPath "$hooks"
14
- exec lefthook install "$@"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-ecoverse/slicc-shared-web",
3
- "version": "2.2.3",
3
+ "version": "2.3.1",
4
4
  "description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration, plus the CDP integration-test harness, for SLICC's web repos",
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",