@ai-ecoverse/slicc-shared-web 2.1.0 → 2.1.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,9 +8,9 @@ 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) |
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)) |
12
12
  | `mcr.config.mjs` | Unit-test coverage for JS and TS sources in `src/` (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
- | `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) | `lint`: `slicc-lint`, and the hooks above |
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` |
15
15
  | `harness/` | The CDP integration-test harness, described [below](#integration-test-harness) | `import { launch } from '@ai-ecoverse/slicc-shared-web/harness'`, and `--test-global-setup=node_modules/@ai-ecoverse/slicc-shared-web/harness/global.mjs` |
16
16
 
@@ -204,6 +204,19 @@ pre-commit:
204
204
  - **No lefthook anywhere:** with `assert_lefthook_installed` (the shared config sets it too) the git hook exits 1 with lefthook's "Can't find lefthook in PATH … Operation is aborted", where it used to print the first line and exit 0.
205
205
  - **Lefthook found, no `node_modules` here:** the generated hook calls the lefthook of the checkout that installed it, by absolute path, so it still runs; but lefthook skips an `extends` file that doesn't exist, which would leave no jobs and pass the commit. The `shared hooks` job lives in the repo's own config, so it runs and fails with `run npm install`.
206
206
 
207
+ ## One hooks directory per worktree
208
+
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
+
211
+ ```json
212
+ "prepare": "slicc-install-hooks"
213
+ ```
214
+
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.
218
+ - **Outside a git checkout** (a packed tarball, say) it does nothing and exits 0.
219
+
207
220
  ## Which unit tests a commit runs
208
221
 
209
222
  The diff-coverage hook, `slicc-unit-cover`, runs only the unit tests that cover the staged change, then `slicc-diff-cover` on their `coverage/unit/lcov.info`, so every staged line in `src/` still has to run:
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
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
10
+ 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.1.0",
3
+ "version": "2.1.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",
@@ -34,6 +34,7 @@
34
34
  "bin": {
35
35
  "slicc-agents-md": "bin/slicc-agents-md.sh",
36
36
  "slicc-diff-cover": "bin/slicc-diff-cover.sh",
37
+ "slicc-install-hooks": "bin/slicc-install-hooks.sh",
37
38
  "slicc-lint": "bin/slicc-lint.sh",
38
39
  "slicc-lint-comments": "bin/slicc-lint-comments.sh",
39
40
  "slicc-memory-peak": "bin/slicc-memory-peak.sh",
@@ -53,6 +54,7 @@
53
54
  "unit"
54
55
  ],
55
56
  "scripts": {
57
+ "prepare": "bin/slicc-install-hooks.sh",
56
58
  "lint": "bin/slicc-lint.sh && shellcheck bin/*.sh",
57
59
  "pretest": "slicc-cdp install-browser",
58
60
  "test": "SLICC_PROFILE=1 node --test --test-global-setup=harness/global.mjs test/integration/*.test.mjs && node test/integration/verify.mjs",