@ai-ecoverse/slicc-shared-web 1.0.0 → 1.1.0
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 +9 -7
- package/bin/slicc-agents-md.sh +23 -0
- package/bin/slicc-diff-cover.sh +4 -0
- package/bin/slicc-lint-comments.sh +11 -1
- package/bin/slicc-lint.sh +10 -0
- package/lefthook.yml +2 -0
- package/mcr.config.mjs +17 -0
- package/package.json +7 -3
package/README.md
CHANGED
|
@@ -5,22 +5,24 @@ Configuration shared by SLICC's web repos ([slicc-bios](https://github.com/ai-ec
|
|
|
5
5
|
| File | What it is | How a repo uses it |
|
|
6
6
|
|---|---|---|
|
|
7
7
|
| `default.json` | Root Renovate preset: automerge on, one dependency per PR, exact pins, 7-day release age (14 for majors, 0 for vulnerability fixes and for our own `@ai-ecoverse` packages, which also jump the PR queue), and a manager for jsDelivr pins inside `src/` | `renovate.json`: `{ "extends": ["github>ai-ecoverse/slicc-shared-web"] }` |
|
|
8
|
-
| `.github/workflows/node-ci.yml` | Reusable CI: `npm ci`, lint, Chromium, integration tests, hotspots in the job summary, coverage/profiles/screenshots as artifacts | `jobs: { ci: { uses: ai-ecoverse/slicc-shared-web/.github/workflows/node-ci.yml
|
|
8
|
+
| `.github/workflows/node-ci.yml` | Reusable CI: `npm ci`, lint, Chromium's system libraries, integration tests, hotspots in the job summary, coverage/profiles/screenshots as artifacts. The browser itself comes from each repo's `pretest` | `jobs: { ci: { uses: ai-ecoverse/slicc-shared-web/.github/workflows/node-ci.yml@vX.Y.Z } }` |
|
|
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, diff coverage | `lefthook.yml`: `extends: [node_modules/@ai-ecoverse/slicc-shared-web/lefthook.yml]` |
|
|
12
|
-
| `
|
|
11
|
+
| `lefthook.yml` | Pre-commit hooks: Biome, typecheck, no comments, no unit tests in git, AGENTS.md, diff coverage | `lefthook.yml`: `extends: [node_modules/@ai-ecoverse/slicc-shared-web/lefthook.yml]` |
|
|
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` | `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`. `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. `slicc-agents-md`, `slicc-no-unit-tests` and `slicc-diff-cover` complete the set | `lint`: `slicc-lint`, and the hooks above |
|
|
13
14
|
|
|
14
|
-
Install it
|
|
15
|
+
Install it from npm, and pin the reusable workflow to the matching `vX.Y.Z` tag. Renovate keeps both current without the usual waiting period:
|
|
15
16
|
|
|
16
17
|
```sh
|
|
17
|
-
npm install --save-dev
|
|
18
|
+
npm install --save-dev --save-exact @ai-ecoverse/slicc-shared-web
|
|
18
19
|
```
|
|
19
20
|
|
|
20
|
-
The hooks expect two scripts in each repo: `test:unit`, which writes `coverage/unit/lcov.info` (unit tests stay out of git), and, in TypeScript repos, `typecheck`. The reusable workflow expects `lint`, plus `test` for the integration tests.
|
|
21
|
+
The hooks expect two scripts in each repo: `test:unit`, which writes `coverage/unit/lcov.info` (unit tests stay out of git), and, in TypeScript repos, `typecheck`. The reusable workflow expects `lint`, plus `test` for the integration tests, with a `pretest` that installs Chromium (`playwright-core install --no-shell chromium`). The diff-coverage hook runs `diff-cover` through `uvx`, so install [uv](https://docs.astral.sh/uv/) once.
|
|
21
22
|
|
|
22
23
|
## Rules every repo follows
|
|
23
24
|
|
|
24
|
-
- No comments anywhere, and no `.md` files except README.md.
|
|
25
|
+
- No comments anywhere, and no `.md` files except README.md and AGENTS.md.
|
|
26
|
+
- Agent guidance committed to a repo lives in AGENTS.md only, at most 1,000 characters per file. The repo has no CLAUDE.md, not even as a symlink, since Claude reads AGENTS.md. The check covers tracked and untracked files; gitignored local files are personal and stay out of it.
|
|
25
27
|
- Unit tests stay out of git, in a gitignored `test/unit/`. The pre-commit hook requires them to execute every staged line in `src/`.
|
|
26
28
|
- Integration tests are committed and run in CI.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -u
|
|
3
|
+
limit=1000
|
|
4
|
+
failed=0
|
|
5
|
+
list="${TMPDIR:-/tmp}/slicc-agents-md.$$"
|
|
6
|
+
git ls-files --cached --others --exclude-standard | grep -E '(^|/)(AGENTS|CLAUDE)\.md$' > "$list" || true
|
|
7
|
+
while IFS= read -r file; do
|
|
8
|
+
case "$file" in
|
|
9
|
+
CLAUDE.md | */CLAUDE.md)
|
|
10
|
+
printf '%s: agent guidance lives in AGENTS.md only, with no CLAUDE.md file or symlink\n' "$file" >&2
|
|
11
|
+
failed=1
|
|
12
|
+
;;
|
|
13
|
+
*)
|
|
14
|
+
chars=$(node -e "process.stdout.write(String([...require('node:fs').readFileSync(process.argv[1], 'utf8')].length))" "$file")
|
|
15
|
+
if [ "$chars" -gt "$limit" ]; then
|
|
16
|
+
printf '%s: %s characters, the limit is %s\n' "$file" "$chars" "$limit" >&2
|
|
17
|
+
failed=1
|
|
18
|
+
fi
|
|
19
|
+
;;
|
|
20
|
+
esac
|
|
21
|
+
done < "$list"
|
|
22
|
+
rm -f "$list"
|
|
23
|
+
exit "$failed"
|
package/bin/slicc-diff-cover.sh
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
#!/bin/sh
|
|
2
2
|
set -eu
|
|
3
|
+
if ! command -v uvx > /dev/null 2>&1; then
|
|
4
|
+
printf 'slicc-diff-cover runs diff-cover through uvx; install uv first: https://docs.astral.sh/uv/getting-started/installation/\n' >&2
|
|
5
|
+
exit 1
|
|
6
|
+
fi
|
|
3
7
|
exec uvx diff-cover@10.6.0 "${1:-coverage/unit/lcov.info}" --compare-branch HEAD --ignore-unstaged --fail-under 100
|
|
@@ -8,4 +8,14 @@ if [ ! -f "$dir/check.mjs" ]; then
|
|
|
8
8
|
curl -fsSL -o "$dir/$file.mjs" "https://raw.githubusercontent.com/ai-ecoverse/slicc/$sha/packages/dev-tools/no-comment/$file.mjs"
|
|
9
9
|
done
|
|
10
10
|
fi
|
|
11
|
-
|
|
11
|
+
report=$(node "$dir/check.mjs" --force "$@" 2>&1) || true
|
|
12
|
+
if [ -z "$report" ]; then
|
|
13
|
+
printf 'slicc-lint-comments: the no-comment checker produced no report\n' >&2
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
rest=$(printf '%s\n' "$report" | grep -vE '^ok: |^(.+/)?AGENTS\.md: documentation file is not allowed' || true)
|
|
17
|
+
if [ -n "$rest" ]; then
|
|
18
|
+
printf '%s\n' "$rest" >&2
|
|
19
|
+
exit 1
|
|
20
|
+
fi
|
|
21
|
+
printf 'ok: no comments, and no documentation besides README.md and AGENTS.md\n'
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
set -eu
|
|
3
|
+
bin=$(dirname "$(readlink -f "$0")")
|
|
4
|
+
npx --no-install biome check .
|
|
5
|
+
if node -e "process.exit(require('./package.json').scripts?.typecheck ? 0 : 1)"; then
|
|
6
|
+
npm run --silent typecheck
|
|
7
|
+
fi
|
|
8
|
+
"$bin/slicc-lint-comments.sh"
|
|
9
|
+
"$bin/slicc-no-unit-tests.sh"
|
|
10
|
+
"$bin/slicc-agents-md.sh"
|
package/lefthook.yml
CHANGED
|
@@ -11,6 +11,8 @@ pre-commit:
|
|
|
11
11
|
run: npx --no-install slicc-lint-comments
|
|
12
12
|
- name: no unit tests in git
|
|
13
13
|
run: npx --no-install slicc-no-unit-tests
|
|
14
|
+
- name: AGENTS.md
|
|
15
|
+
run: npx --no-install slicc-agents-md
|
|
14
16
|
- name: diff coverage
|
|
15
17
|
glob: "src/**.{js,mjs,ts}"
|
|
16
18
|
run: npm run --silent test:unit && npx --no-install slicc-diff-cover
|
package/mcr.config.mjs
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { stripTypeScriptTypes } from 'node:module';
|
|
2
|
+
|
|
3
|
+
const strip = (entry) => {
|
|
4
|
+
if (entry.url.endsWith('.ts')) entry.source = stripTypeScriptTypes(entry.source);
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const ours = (url) =>
|
|
8
|
+
url.includes('/src/') && !url.includes('/node_modules/') && /\.(m?js|ts)$/.test(url);
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
name: process.env.npm_package_name ?? 'unit',
|
|
12
|
+
outputDir: 'coverage/unit',
|
|
13
|
+
reports: ['lcovonly', 'console-details'],
|
|
14
|
+
all: { dir: 'src', filter: '**/*.{js,mjs,ts}', transformer: strip },
|
|
15
|
+
entryFilter: (entry) => ours(entry.url),
|
|
16
|
+
onEntry: strip,
|
|
17
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-ecoverse/slicc-shared-web",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Shared Renovate, Biome, TypeScript, lefthook and GitHub Actions configuration for SLICC's web repos",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -25,10 +25,13 @@
|
|
|
25
25
|
"./biome": "./biome.json",
|
|
26
26
|
"./tsconfig.json": "./tsconfig.json",
|
|
27
27
|
"./lefthook.yml": "./lefthook.yml",
|
|
28
|
-
"./package.json": "./package.json"
|
|
28
|
+
"./package.json": "./package.json",
|
|
29
|
+
"./mcr.config.mjs": "./mcr.config.mjs"
|
|
29
30
|
},
|
|
30
31
|
"bin": {
|
|
32
|
+
"slicc-agents-md": "bin/slicc-agents-md.sh",
|
|
31
33
|
"slicc-diff-cover": "bin/slicc-diff-cover.sh",
|
|
34
|
+
"slicc-lint": "bin/slicc-lint.sh",
|
|
32
35
|
"slicc-lint-comments": "bin/slicc-lint-comments.sh",
|
|
33
36
|
"slicc-no-unit-tests": "bin/slicc-no-unit-tests.sh"
|
|
34
37
|
},
|
|
@@ -37,10 +40,11 @@
|
|
|
37
40
|
"biome.json",
|
|
38
41
|
"default.json",
|
|
39
42
|
"lefthook.yml",
|
|
43
|
+
"mcr.config.mjs",
|
|
40
44
|
"tsconfig.json"
|
|
41
45
|
],
|
|
42
46
|
"scripts": {
|
|
43
|
-
"lint": "
|
|
47
|
+
"lint": "bin/slicc-lint.sh && shellcheck bin/*.sh",
|
|
44
48
|
"trust": "npx fledgling sync -y --skip-publish",
|
|
45
49
|
"trust:dry": "npx fledgling sync --dry-run -y --skip-publish",
|
|
46
50
|
"release": "semantic-release"
|