@shaulavo/standards 0.1.2 → 0.1.3

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.
@@ -0,0 +1,73 @@
1
+ ---
2
+ name: standards
3
+ description: Start a repository from @shaulavo/standards, adopt its shared quality gates in an existing repository, land shrink-only baselines through a data PR before a gate PR, read gate failures and CI reports, merge with standards merge, and keep product checks consumer-owned. Use when setting up, changing, or debugging @shaulavo/standards gates, baselines, CI workflows, or repository contracts.
4
+ license: MIT
5
+ ---
6
+
7
+ # Standards workflow
8
+
9
+ Follow [docs/repo-contract.md](https://github.com/ShaulLavo/standards/blob/main/docs/repo-contract.md) as the single written source for what a consumer repository looks like. Run `standards doctor` to verify every observable contract rule; each failure names the matching anchor in `docs/repo-contract.md`.
10
+
11
+ ## Starting a new repository
12
+
13
+ Use `standards new` for greenfield repositories only. Never run an unsolicited `copier copy` over an existing codebase.
14
+
15
+ ```sh
16
+ bunx @shaulavo/standards@<version> new my-lib --preset ts-library
17
+ ```
18
+
19
+ `standards new` requires Bun, Git, and the pinned Copier release (`uv tool install copier==9.19.1`). It renders the task-free template in a staging directory, checks `.standards.json` against the installed package version, initializes Git, and runs `bun install`. Run `bun run check` inside the new directory before the first commit.
20
+
21
+ ## Adopting in an existing repository
22
+
23
+ Adopt through a reviewed pull request, one gate set at a time:
24
+
25
+ 1. **Choose the CI path.** Use the reusable workflow (`ShaulLavo/standards/.github/workflows/check.yml@<40-hex-sha> # vX.Y.Z`) when static checks form their own job. Use `ShaulLavo/standards/actions/setup@<40-hex-sha> # vX.Y.Z` plus gate steps inside an existing job when checks share a build or test job. Private repositories without GitHub Actions ship no workflow files and post exact local `bun run check` commands and results in each pull request.
26
+ 2. **Pin versions in one place.** Add `@shaulavo/standards` at an exact version and `typescript` 7 or later (ts-go) to `devDependencies`. Remove direct dependencies on tools `@shaulavo/standards` owns (`oxlint`, `oxfmt`, `knip`, `jscpd`, `unknot`, `publint`, `oxc-plugin-react-compiler`). Pin every external GitHub Action by full 40-hex commit SHA with a trailing `# vX.Y.Z` comment.
27
+ 3. **Extend shared presets.** Point `.oxlintrc.json` at `./node_modules/@shaulavo/standards/config/oxlint/base.json` (or `react.json` whenever any workspace package depends on `react`). Point `tsconfig.json` at `@shaulavo/standards/config/tsconfig/{bun,dom,nodenext}.json`. Keep formatting on Oxfmt with `.oxfmtignore`; remove Prettier dependencies and configs. Document any local override with a reason comment.
28
+ 4. **Preserve invariants before deleting duplicate wrappers.** Before removing local jscpd, source-language, or Unknot scripts, confirm every invariant they enforced has a test covering it, and search the repository to prove no remaining caller reads the deleted files or flags.
29
+ 5. **Keep net job count flat or lower.** Record hosted jobs per pull request and per `main` push before and after adoption. Update any aggregate verdict job to read the new job IDs, and confirm the emitted `<caller job id> / check` context on a real run before retiring an old required check.
30
+ 6. **Add update wiring.** Keep `renovate.json` extending `github>ShaulLavo/standards//renovate/default` and `AGENTS.md` with a `## Verification map` section plus a `CLAUDE.md` symlink pointing to `AGENTS.md`.
31
+
32
+ ## Adding or relocating a baseline
33
+
34
+ `standards dupes` and `standards structure` run in zero mode by default: any finding fails, with no Git history required. Use a baseline only when adopting existing debt.
35
+
36
+ A baseline missing at the comparison base allows nothing, so every new or relocated baseline lands in two pull requests:
37
+
38
+ 1. **Data PR.** Land `.baselines/dupes.json` or `.baselines/structure.json` while the previous gate or zero mode is still active. Every entry needs a non-empty `key`, a positive integer `allowance`, and a non-empty `reason`. Review the baseline file as data.
39
+ 2. **Gate PR.** Turn on `standards dupes` or `standards structure` once the data PR is on the base branch.
40
+
41
+ Baselines only shrink:
42
+
43
+ - Run `standards dupes --shrink` or `standards structure --shrink` after fixing debt to delete stale entries and lower allowances while preserving consumer-owned extra fields and entry order.
44
+ - Never add an entry or raise an allowance silently; edit by hand in a reviewed pull request only when justified.
45
+
46
+ ## Reading gate failures and CI reports
47
+
48
+ Every gate distinguishes findings from untrustworthy runs:
49
+
50
+ - **Exit 0:** scanned at least one input and found zero problems.
51
+ - **Exit 1:** scanned inputs and found policy violations (lint errors, formatting diffs, unused code, baseline growth, stale entries, or contract violations). Fix the code, shrink stale baseline entries, or add a reasoned inline `oxlint-disable-next-line <rule> -- <reason>` only when the rule cannot be satisfied cleanly.
52
+ - **Exit 2:** fail-closed stop. Causes include a missing or unextended config, a rejected flag that weakens enforcement, zero scanned inputs, a missing comparison base in baseline mode, an older `@shaulavo/standards` than `.standards.json` `minVersion`, or malformed analyzer output. Read the stderr line for the exact remediation command.
53
+
54
+ When `STANDARDS_REPORT_DIR` is set in CI, each gate records its status, summary, failure excerpt, and duration. `standards report --status <outcome> --comment` renders those records to `GITHUB_STEP_SUMMARY` and updates one sticky pull request comment (`<!-- standards:ci-report:check -->`). Inspect the failed gate row's excerpt first, then reproduce with the same `bun run check` command locally.
55
+
56
+ ## Merging with `standards merge`
57
+
58
+ Use `standards merge <pr>` (or `--dry-run` first) instead of bypassing branch checks. It merges via `gh pr merge <pr> --squash --match-head-commit <head>` only when five checks hold:
59
+
60
+ 1. The pull request is open and not a draft.
61
+ 2. An effective writer (`admin`, `maintain`, or `write` permission) posted a visible top-level `APPROVE @ <40-hex-sha>` verdict with no later `CHANGES REQUESTED` or ambiguous edit.
62
+ 3. `head` equals the approved SHA, or every file changed since the approved ancestor SHA is Markdown (`*.md`).
63
+ 4. The base branch has no active merge queue.
64
+ 5. Every required check from branch protection and rulesets passed on `head` in the latest check suite.
65
+
66
+ If `standards merge` refuses, fix the named condition rather than working around the guard.
67
+
68
+ ## Preserving consumer-owned product checks
69
+
70
+ Keep builds, unit and integration tests, release workflows, and product verification inside the consumer repository. Do not move product-specific rules or names into `@shaulavo/standards`.
71
+
72
+ - **Libraries:** build once, pack with `npm pack --ignore-scripts`, run `standards publint <tarball>` on that tarball, and install the same tarball into an isolated consumer to import and exercise its public exports.
73
+ - **Apps, CLIs, and services:** keep a `## Verification map` in `AGENTS.md`, maintain a project-local verification skill (for example `.agents/skills/verify-<app>/`, or `.cursor/skills/verify-<app>/` via **create-verification-skill** on Cursor), and keep its feature map current with the **maintain-verification-skill** skill.