@maniumek/suwgate 0.15.0 → 0.17.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.
Files changed (80) hide show
  1. package/AGENTS.shared.md +13 -2
  2. package/README.md +95 -9
  3. package/dist/cli.js +208 -12
  4. package/dist/eslint/index.d.ts +1 -0
  5. package/dist/eslint/index.js +20 -1
  6. package/dist/gate/breakdown.d.ts +38 -0
  7. package/dist/gate/breakdown.js +107 -0
  8. package/dist/gate/check.d.ts +3 -0
  9. package/dist/gate/check.js +37 -1
  10. package/dist/gate/config.d.ts +5 -1
  11. package/dist/gate/config.js +56 -2
  12. package/dist/gate/context.d.ts +15 -0
  13. package/dist/gate/context.js +97 -0
  14. package/dist/gate/contract.d.ts +7 -0
  15. package/dist/gate/contract.js +1 -0
  16. package/dist/gate/dashboard.d.ts +107 -0
  17. package/dist/gate/dashboard.js +126 -0
  18. package/dist/gate/dashboardFile.d.ts +31 -0
  19. package/dist/gate/dashboardFile.js +154 -0
  20. package/dist/gate/dashboardJson.d.ts +2 -0
  21. package/dist/gate/dashboardJson.js +25 -0
  22. package/dist/gate/dashboardPage.d.ts +3 -0
  23. package/dist/gate/dashboardPage.js +294 -0
  24. package/dist/gate/dashboardServer.d.ts +11 -0
  25. package/dist/gate/dashboardServer.js +70 -0
  26. package/dist/gate/dashboardTesting.d.ts +12 -0
  27. package/dist/gate/dashboardTesting.js +98 -0
  28. package/dist/gate/guardsStep.d.ts +6 -0
  29. package/dist/gate/guardsStep.js +8 -1
  30. package/dist/gate/history.d.ts +28 -0
  31. package/dist/gate/history.js +72 -0
  32. package/dist/gate/plan.d.ts +3 -1
  33. package/dist/gate/plan.js +6 -3
  34. package/dist/gate/repository.d.ts +1 -0
  35. package/dist/gate/repository.js +1 -1
  36. package/dist/gate/runner.d.ts +3 -0
  37. package/dist/gate/runner.js +4 -1
  38. package/dist/gate/stats.d.ts +27 -0
  39. package/dist/gate/stats.js +84 -0
  40. package/dist/guards/comments/eslint.js +1 -0
  41. package/dist/guards/comments/scan.js +1 -0
  42. package/dist/guards/comments/switches.js +1 -0
  43. package/dist/guards/database/connectionHost.js +1 -0
  44. package/dist/guards/dotnet/appsettingsBound.js +1 -0
  45. package/dist/guards/dotnet/bannedNugetPackages.js +1 -0
  46. package/dist/guards/dotnet/openApiVersions.js +1 -0
  47. package/dist/guards/dotnet/suwbackkitWiring.js +1 -0
  48. package/dist/guards/dotnet/unusedNugetVersions.js +1 -0
  49. package/dist/guards/repository/bannedNpmPackages.js +1 -0
  50. package/dist/guards/repository/composePorts.js +1 -0
  51. package/dist/guards/repository/dependencyDirection.js +1 -0
  52. package/dist/guards/repository/forbiddenNames.js +1 -0
  53. package/dist/guards/repository/humanDocs.js +1 -0
  54. package/dist/guards/repository/imagePins.js +1 -0
  55. package/dist/guards/repository/justModules.js +1 -0
  56. package/dist/guards/repository/noRawColors.js +1 -0
  57. package/dist/guards/repository/repositoryLayout.js +1 -0
  58. package/dist/guards/repository/scriptsCalled.js +1 -0
  59. package/dist/guards/repository/scriptsHelp.js +1 -0
  60. package/dist/guards/repository/suwfrontkitWiring.js +1 -0
  61. package/dist/guards/repository/vsCodeSettings.js +1 -0
  62. package/dist/profiles/holdout.d.ts +2 -0
  63. package/dist/profiles/holdout.js +38 -0
  64. package/dist/profiles/index.d.ts +1 -0
  65. package/dist/profiles/index.js +1 -0
  66. package/dist/profiles/node.d.ts +1 -0
  67. package/dist/profiles/node.js +12 -4
  68. package/dist/profiles/reports.d.ts +6 -0
  69. package/dist/profiles/reports.js +14 -0
  70. package/dist/profiles/verdict.js +45 -3
  71. package/dist/session/doctor.d.ts +26 -0
  72. package/dist/session/doctor.js +265 -0
  73. package/dist/session/gardenRecord.d.ts +12 -0
  74. package/dist/session/gardenRecord.js +58 -0
  75. package/dist/session/guardPr.js +2 -2
  76. package/dist/session/prePush.js +1 -1
  77. package/dist/session/suwagentInfo.d.ts +28 -0
  78. package/dist/session/suwagentInfo.js +103 -0
  79. package/package.json +3 -1
  80. package/schema/suwgate.schema.json +26 -0
package/AGENTS.shared.md CHANGED
@@ -13,8 +13,9 @@ repository's own `AGENTS.md` adds what is only its own, and wins where it says o
13
13
  - While building, on a feature branch: `suwgate check --quick` runs after every turn, and `suwgate step <step> [-- <tool args>]` runs
14
14
  one step (`suwgate step` lists them). The full gate runs only in CI: an agent never runs `suwgate check` itself. `AGENTS.md` says
15
15
  how this repository runs suwgate.
16
- - Done building? `/suwagent:ship`: it simplifies the change, runs `suwgate ship` (the quick gate and the changed e2e tests, which
17
- writes the ship record), pushes, opens the pull request, waits for CI, fixes a red run and writes the PR proof. A push or a pull
16
+ - Done building? `/suwgate:ship`: a small change gets the gate only, a normal one also simplify and review, a careful one cannot drop the review.
17
+ It runs `suwgate ship` (the quick gate and the changed e2e tests, which writes the ship record), pushes, opens the pull request,
18
+ waits for CI, fixes a red run and writes the PR proof. A push or a pull
18
19
  request without a ship record for its commit is refused; a person without the plugin runs `suwgate ship` before pushing.
19
20
  - What the PR proof shows, by the kind of change: a refactor, optimisation, performance or stability change none ("behaviour
20
21
  unchanged"); a UI change screenshots and video, before and after; a behaviour change one scenario, before and after; a new
@@ -26,6 +27,16 @@ repository's own `AGENTS.md` adds what is only its own, and wins where it says o
26
27
  `AGENTS.md` only for what none of these can check.
27
28
  - A guard's message states the fix. Never weaken a guard to make a change pass: fix the change.
28
29
  - Mutation tests run only when a person asks for them: an agent neither runs nor proposes them on its own.
30
+ - `suwgate stats` shows what the gate caught and how long it took: read it before proposing a new guard or calling one useless.
31
+ - `suwgate doctor` checks that the main branch takes only a change whose gate passed in CI. It is read-only: the owner fixes what
32
+ it reports.
33
+ - Holdout scenarios live outside the repository and run in CI only. A red `holdout` step names the scenarios that failed: fix the
34
+ behaviour, never ask to see or change a scenario, and never write a test meant to stand in for one.
35
+ - `guardSets`: the guards of no set always run, and a set is taken in `suwgate.yml`, which an agent never edits.
36
+ - `suwgate dashboard` writes one read-only page with what the gate caught, the wall, the criteria and the cleaning: run it to show the
37
+ owner the state of the repository, never to check it (it is not a gate run). `/suwgate:garden` ends with `suwgate garden-ran <kind>=<count> ...`.
38
+ An agent answers questions about the gate's state from `suwgate dashboard --json`; the suwgate plugin's `insights` skill says how to read it.
39
+ Plain `suwgate dashboard` ends; `suwgate dashboard --serve` does not, so an agent starts it only in the background and only when the owner asks.
29
40
 
30
41
  ## Git
31
42
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  <picture>
2
2
  <source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/hero-dark.png">
3
- <img alt="suwgate, npm CLI and NuGet guards. One quality gate for every repository: one command runs the steps of its profiles and its guards, configured in one suwgate.yml. Tags: suwgate check, agent hooks, suwgate dev, CI workflows, Renovate preset. Terminal: suwgate check --quick prints PASS, all 8 steps in 4s (14 exceptions in suwgate.yml); suwgate step dotnet-test prints PASS, all 2 steps in 55s. Numbers: 4 profiles (web, library, dotnet, database), 25 steps the profiles bring, 36 repository guards, 14 .NET guards in xUnit, 3 hooks for agents and git, 3 reusable CI workflows." src="docs/visual/board/img/readme/hero-light.png" width="100%">
3
+ <img alt="suwgate, npm CLI and NuGet guards. One quality gate for every repository: one command runs the steps of its profiles and its guards, configured in one suwgate.yml. Tags: suwgate check, agent hooks, suwgate dev, CI workflows, Renovate preset. Terminal: suwgate check --quick prints PASS, all 8 steps in 4s (14 exceptions in suwgate.yml); suwgate step dotnet-test prints PASS, all 2 steps in 55s. Numbers: 4 profiles (web, library, dotnet, database), 25 steps the profiles bring, 36 repository guards, 14 .NET guards in xUnit, 5 hooks for agents and git, 3 reusable CI workflows." src="docs/visual/board/img/readme/hero-light.png" width="100%">
4
4
  </picture>
5
5
 
6
6
  suwgate is the one quality gate of a stack of repositories that agents and one developer work on: the CLI
@@ -49,7 +49,7 @@ Wiring the hooks (`.claude/settings.json`, `.githooks/pre-commit`) and every oth
49
49
 
50
50
  <picture>
51
51
  <source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/flow-dark.png">
52
- <img alt="How a change goes through it. On your machine: an agent edits, and guard-edit runs before every edit (gate files refused; lockfiles, API types and migrations refused); the turn ends, and stop runs the quick gate within 20 seconds (guards and changed files, skipped when nothing changed); git commit runs pre-commit (gitleaks, then the quick gate; staged secrets refused); before done, suwgate check runs the full gate (every step, in parallel, browser tests included). In CI, gate.yml: proof asks whether the tree already passed, in a few seconds (a green ci/tree stamp of the same tree skips the gate); gate runs suwgate check --verbose (a SKIP fails in CI); stack runs the smoke test when smoke is true (its own compose project, free ports); stamp writes ci/tree after green (the merge push is proven); release with release-npm or release-nuget (the publish job stays in the caller). Every step has a ceiling; a missing tool is SKIP, and SKIP fails in CI; exit 0 green, 1 red, 2 usage or suwgate.yml problem." src="docs/visual/board/img/readme/flow-light.png" width="100%">
52
+ <img alt="How a change goes through it. On your machine: an agent edits, and guard-edit runs before every edit (gate files refused; lockfiles, API types and migrations refused); the turn ends, and stop runs the quick gate within 20 seconds (guards and changed files, skipped when nothing changed); git commit runs pre-commit (gitleaks, then the quick gate; staged secrets refused); before done, suwgate ship runs the quick gate and the e2e tests of the changed files and records the tree; an agent never runs the full gate, CI does. In CI, gate.yml: proof asks whether the tree already passed, in a few seconds (a green ci/tree stamp of the same tree skips the gate); gate runs suwgate check --verbose, every step in parallel, browser tests and the holdout scenarios included (a SKIP fails in CI); stack runs the smoke test when smoke is true (its own compose project, free ports); stamp writes ci/tree after green (the merge push is proven); release with release-npm or release-nuget (the publish job stays in the caller). Every step has a ceiling; a missing tool is SKIP, and SKIP fails in CI; exit 0 green, 1 red, 2 usage or suwgate.yml problem." src="docs/visual/board/img/readme/flow-light.png" width="100%">
53
53
  </picture>
54
54
 
55
55
  The quick gate is what an agent meets after every turn, so it has a time budget; the full gate is what CI runs. A step that cannot
@@ -59,7 +59,7 @@ run here (its tool is missing) is reported as not verified, never as passed.
59
59
 
60
60
  <picture>
61
61
  <source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/gate-dark.png">
62
- <img alt="The gate: profiles and their steps. web, a web app: pnpm-install, typecheck, lint, unit-tests, format, knip, e2e (Playwright, fresh database). library, an npm package: the Node steps, stories, publint, attw, consumer-app, visual, changeset (packed as npm ships it). dotnet, a .NET solution: dotnet-build, dotnet-format, dotnet-test, which runs the .NET guards (xUnit v3, CSharpier). database, PostgreSQL: database-up, the database guards, migrations stay unchanged (compose or your script). web and dotnet together: api-contract, api-version (oasdiff), contract-pins. Every repository: guards, compose, criteria, criteria-ran, shellcheck, gitleaks. Proof, not presence: 0 tests fail (Vitest, Playwright and xUnit reports, a run with no test is red); .NET evidence (every .NET guard of the profiles writes that it ran, or dotnet-test fails); configs in effect (tsc --showConfig and eslint --print-config keep the strict options on); criteria-ran (each acceptance criterion a test names ran and passed in this run). --quick: the guards and the quick steps, only for what changed since master, budget 20 s (quick.limitSeconds, SUWGATE_QUICK_LIMIT)." src="docs/visual/board/img/readme/gate-light.png" width="100%">
62
+ <img alt="The gate: profiles and their steps. web, a web app: pnpm-install, typecheck, lint, unit-tests, format, knip, e2e (Playwright, fresh database). library, an npm package: the Node steps, stories, publint, attw, consumer-app, visual, changeset (packed as npm ships it). dotnet, a .NET solution: dotnet-build, dotnet-format, dotnet-test, which runs the .NET guards (xUnit v3, CSharpier). database, PostgreSQL: database-up, the database guards, migrations stay unchanged (compose or your script). web and dotnet together: api-contract, api-version (oasdiff), contract-pins. Every repository: guards, compose, criteria, criteria-ran, shellcheck, gitleaks; holdout when suwgate.yml has the key holdout (scenarios kept outside the repository, CI only). Proof, not presence: 0 tests fail (Vitest, Playwright and xUnit reports, a run with no test is red); .NET evidence (every .NET guard of the profiles writes that it ran, or dotnet-test fails); configs in effect (tsc --showConfig and eslint --print-config keep the strict options on); criteria-ran (each acceptance criterion a test names ran and passed in this run). --quick: the guards and the quick steps, only for what changed since master, budget 20 s (quick.limitSeconds, SUWGATE_QUICK_LIMIT)." src="docs/visual/board/img/readme/gate-light.png" width="100%">
63
63
  </picture>
64
64
 
65
65
  Independent steps run in parallel, and each looks only where its profile lives. The steps of each profile, the criteria kinds and
@@ -72,6 +72,7 @@ what each step proves: [docs/usage.md](docs/usage.md#the-steps-of-the-profiles).
72
72
  <img alt="The guards. Repository guards, 36, in-process, the step guards. Agents: agents-shared, agents-file, hooks, human-docs, docs-paths. Layout and names: repository-layout, forbidden-names, required-files, just-modules. Configs: config-contents, vscode-settings, image-pins, compose-ports. Scripts: scripts-called, scripts-help (answers --help). Dependencies: banned-npm-packages, banned-nuget-packages, unused-nuget-versions, dependency-direction. No comments: comments-hash, comments-css, comments-json, comments-markup, comments-sql, comments-csharp, comments-eslint, no-in-place-switches. Tests: test-timing, tests drive a fake clock, never real time. Kits wired: suwfrontkit-wiring, suwbackkit-wiring, openapi-versions, no-raw-colors, appsettings-bound. Database: connection-host, migrations-unchanged. Criteria: criteria-kinds, a repository's own kinds of guardrail are explained. .NET guards, NuGet, one xUnit test calls SuwgateGuards.VerifyAll. Suwgate.Architecture: architecture/ layers, endpoints, project-references, every-project-guarded, interfaces-have-two-implementations, nothing-obsolete, no-unused-types, forbidden-type-names, unique-type-names, one-type-per-file, no-escape-hatches, no-fixture-in-field, build-settings; and the build defaults: warnings as errors, analyzers, banned APIs. Suwgate.Database: database/ migration-script-names, NNNN_snake_case.sql, each number once. suwgate.yml: exceptions let one target through one guard, with a reason; a stale one fails; once: true for one branch; guards.skip and steps.skip, with a reason." src="docs/visual/board/img/readme/guards-light.png" width="100%">
73
73
  </picture>
74
74
 
75
+ Guards that keep the gate honest always run; those that encode the owner's stack form the set `stack`, which a repository takes (the default) or leaves out with `guardSets` in `suwgate.yml`.
75
76
  A guard reports every finding with its fix and never decides an exception itself: `suwgate.yml` holds the exceptions, each with
76
77
  its reason. The .NET guards and build defaults: [Suwgate.Architecture](dotnet/Suwgate.Architecture/README.md).
77
78
 
@@ -79,9 +80,11 @@ its reason. The .NET guards and build defaults: [Suwgate.Architecture](dotnet/Su
79
80
 
80
81
  <picture>
81
82
  <source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/agents-dark.png">
82
- <img alt="For agents. hook guard-edit, Claude Code PreToolUse: refuses an edit of the gate (suwgate.yml, hooks, workflows, lint and type configs) and of generated files; ALLOW_GATE_EDIT=1 lifts the gate part. hook stop, Claude Code Stop: runs the quick gate after every turn, unless nothing changed since it last passed; red, the agent keeps working. hook pre-commit, git: gitleaks on the staged changes, then the quick gate; .githooks/pre-commit. AGENTS.shared.md: the rules every repository shares (test last, git, specs, names, secrets, no comments); suwgate agents-shared writes the copy; the agents-shared guard fails until it is current and AGENTS.md reads it first. Acceptance criteria as guardrails: every criterion id of a spec in docs/visual/spec/ is named by a test, a lint rule or a build rule (criteria), and the tests that name it ran and passed (criteria-ran)." src="docs/visual/board/img/readme/agents-light.png" width="100%">
83
+ <img alt="For agents. hook guard-edit, Claude Code PreToolUse: refuses an edit of the gate (suwgate.yml, hooks, workflows, lint and type configs) and of generated files; ALLOW_GATE_EDIT=1 lifts the gate part. hook stop, Claude Code Stop: runs the quick gate after every turn, unless nothing changed since it last passed; red, the agent keeps working. hook pre-commit, git: gitleaks on the staged changes, then the quick gate; .githooks/pre-commit. AGENTS.shared.md: the rules every repository shares (test last, git, specs, names, secrets, no comments); suwgate agents-shared writes the copy; the agents-shared guard fails until it is current and AGENTS.md reads it first. Acceptance criteria as guardrails: every criterion id of a spec in docs/visual/spec/ is named by a test, a lint rule or a build rule (criteria), and the tests that name it ran and passed (criteria-ran). suwgate stats shows what the gate caught; suwgate doctor checks that the main branch takes only a change whose gate passed. Holdout scenarios: tests outside the repository that only name what failed." src="docs/visual/board/img/readme/agents-light.png" width="100%">
83
84
  </picture>
84
85
 
86
+ Holdout scenarios keep end-to-end tests outside the repository, run only in CI: the agent learns which scenarios failed, never what they say ([docs/usage.md](docs/usage.md#holdout-scenarios-tests-the-agent-cannot-see-or-edit)).
87
+
85
88
  ## suwgate dev
86
89
 
87
90
  <picture>
@@ -127,14 +130,14 @@ self-hosted runners: [ci/self-hosted](ci/self-hosted/README.md).
127
130
 
128
131
  <picture>
129
132
  <source media="(prefers-color-scheme: dark)" srcset="docs/visual/board/img/readme/choose-dark.png">
130
- <img alt="Which command, when. While an agent works, after every turn: suwgate check --quick (the Stop hook). Before calling a change done: suwgate check (the full gate). Which steps does this repository have: suwgate step (lists them). One step, with what it needs, and its tool's flags: suwgate step e2e -- --headed. Run the whole local stack: suwgate dev tmux start. The server failed, why: suwgate dev logs. A linked worktree needs its own databases and ports: suwgate dev checkout-env, with eval. A sibling repository's images are behind its checkout: suwgate dev sibling name up. suwgate was upgraded and agents-shared is red: suwgate agents-shared (writes the copy)." src="docs/visual/board/img/readme/choose-light.png" width="100%">
133
+ <img alt="Which command, when. While an agent works, after every turn: suwgate check --quick (the Stop hook). Before calling a change done: suwgate ship (the quick gate and the changed e2e tests; the full gate runs in CI). What did the gate catch: suwgate stats. Is the main branch protected: suwgate doctor. Which steps does this repository have: suwgate step (lists them). One step, with what it needs, and its tool's flags: suwgate step e2e -- --headed. Run the whole local stack: suwgate dev tmux start. The server failed, why: suwgate dev logs. A linked worktree needs its own databases and ports: suwgate dev checkout-env, with eval. A sibling repository's images are behind its checkout: suwgate dev sibling name up. suwgate was upgraded and agents-shared is red: suwgate agents-shared (writes the copy)." src="docs/visual/board/img/readme/choose-light.png" width="100%">
131
134
  </picture>
132
135
 
133
136
  <details>
134
137
  <summary>suwgate --help</summary>
135
138
 
136
139
  ```text
137
- usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verbose] [-- <args>]] | suwgate hook <guard-edit|stop|pre-commit> | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
140
+ usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verbose] [-- <args>]] | suwgate hook <guard-edit|guard-pr|stop|pre-commit|pre-push> | suwgate ship | suwgate stats [--days <n>] [--json] | suwgate doctor | suwgate context | suwgate dashboard [--days <n>] [--out <path> | --serve [--port <n>] | --json] | suwgate garden-ran <kind>=<count>... | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
138
141
  suwgate check every step of the repository's profiles (suwgate.yml) and the repository guards
139
142
  suwgate check --quick the guards, and the quick steps only for what changed since master; has a time budget
140
143
  (SUWGATE_QUICK_LIMIT seconds, default 20) because the Stop hook runs it after every turn
@@ -147,23 +150,106 @@ usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verb
147
150
  suwgate hook guard-edit Claude Code PreToolUse hook: refuses an agent's edit of the gate and of generated files
148
151
  (ALLOW_GATE_EDIT=1 lifts the gate part for one session); only files of its own project
149
152
  (CLAUDE_PROJECT_DIR, else the git checkout it runs in), with the lists of its profiles
153
+ suwgate hook guard-pr Claude Code PreToolUse hook for Bash: refuses gh pr create and the commands of
154
+ settings.hooks.prCommands while the HEAD tree has no ship record, and --no-verify always
150
155
  suwgate hook stop Claude Code Stop hook: runs the quick gate unless nothing changed since it last passed
151
156
  suwgate hook pre-commit git pre-commit hook: gitleaks on the staged changes, then the quick gate
157
+ suwgate hook pre-push git pre-push hook: refuses a push of a branch whose tree has no ship record
158
+ suwgate ship needs a clean working tree: runs the quick gate and the e2e tests whose files changed on the
159
+ branch, then records the tree (the pre-push and guard-pr hooks let a push of it through)
160
+ suwgate stats what the gate caught: runs and red share per mode, quick gate times and budget overruns, the slowest
161
+ steps, the guards by findings and the guards with none, from suwgate-runs.jsonl in the git common
162
+ directory (every run of check, ship, the Stop and pre-commit hooks appends a line there; step does not)
163
+ --days <n> the period (30 by default), --json the same numbers as one JSON object
164
+ suwgate doctor is the wall up: reads the rules and the branch protection of the main branch through gh and fails
165
+ when it needs no pull request, requires no status check or not the gate's, allows force pushes or
166
+ deletion, or when core.hooksPath and the hooks are not wired here; exit 2 when gh cannot answer
167
+ (not installed, not logged in, no GitHub remote); read-only, needs the network, never part of the gate
168
+ suwgate context a short plain-text map for an agent (at most 1,800 characters): how work reaches a pull request here,
169
+ the version, profiles, unwired hooks and the last run on this branch, where to look; local data only, no
170
+ network, no gate run; empty output without a valid suwgate.yml; the plugin's SessionStart hook prints it
171
+ suwgate dashboard one self-contained, read-only HTML page with the whole method of this repository: what needs the owner,
172
+ the wall (as suwgate doctor reads it), runs, what broke and on which branch, what the repository has,
173
+ which acceptance criteria have a test, the installed suwagent and the last cleaning; written to
174
+ suwgate-dashboard.html in the git common directory (--out <path> elsewhere), the path is printed;
175
+ --days <n> the period (30 by default); never runs the gate and never records a run; exit 2 on a bad suwgate.yml
176
+ suwgate dashboard --json
177
+ the data of the page as one JSON object on stdout (schemaVersion, attention, wall, runs, stopped,
178
+ branches, steps, guards, exceptions, hooks, quietGuards, criteria, plugin, garden, about), no file
179
+ suwgate dashboard --serve [--port <n>]
180
+ the same page live, at http://127.0.0.1:<port>/ (4780, else the next free port), for a browser tab kept
181
+ open beside the work: it follows new runs, cleaning traces and changes of suwgate.yml within seconds and
182
+ keeps the opened parts open; answers only this machine, asks GitHub for the wall at most every 5 minutes,
183
+ writes nothing; runs until interrupted, so start it in the background suwgate garden-ran <kind>=<count> ...
184
+ records a cleaning run (e.g. suwgate garden-ran docs=3 guards=2) as one line of suwgate-garden.jsonl in the
185
+ git common directory, which suwgate dashboard shows; a kind is a kebab-case word, a count a whole number
152
186
  suwgate dev <db|logs|smoke|server|tmux|sibling|api-types|slow-tests|checkout-env>
153
187
  the local stack of the repository (the dev section of suwgate.yml), and the images of the
154
188
  sibling repositories it runs, rebuilt from their checkouts when stale, the API contract and types regenerated
155
- from the server, and a report of the slowest .NET tests; suwgate dev --help
189
+ from the server, and a report of the slowest tests; suwgate dev --help
156
190
  suwgate agents-shared writes AGENTS.shared.md, the rules every repository shares, as this suwgate ships it, into the
157
191
  repository root (the agents-shared guard fails until the copy is current)
158
- suwgate verdict <tests|guards|tsconfig|eslint> ...
192
+ suwgate verdict <tests|holdout|guards|tsconfig|eslint> ...
159
193
  what the steps call after their tool: did tests run, did the .NET guards run (evidence),
160
- are the strict compiler options and the eslint rules in effect
194
+ are the strict compiler options and the eslint rules in effect, which holdout scenarios failed
161
195
  Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step whose tool is missing is SKIP,
162
196
  and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.
163
197
  ```
164
198
 
165
199
  </details>
166
200
 
201
+ ## Claude Code plugin
202
+
203
+ The `suwgate` plugin teaches Claude Code the CLI and lets an agent read what the gate knows. It is installed from this repository's marketplace, not from npm. It has one hook, at session start, which only prints `suwgate context` (a short map of how work reaches a pull request here and where the gate stands; nothing when the repository has no suwgate). It wires none of the gate's own hooks: those are wired per repository in `.claude/settings.json` and `core.hooksPath`, and the `hooks` guard and `suwgate doctor` check them.
204
+
205
+ The suwgate plugin works with the suwagent plugin ([Manomenu/suwalski-agent-plugin](https://github.com/Manomenu/suwalski-agent-plugin)): the spec pages with acceptance criteria, the review page and the PR proof that `/suwgate:ship` asks for come from it. Install both, suwagent first, each with auto-update on. suwagent never depends on suwgate.
206
+
207
+ Follow these steps in order; each has the form a person types in a session and the form an agent runs in a shell.
208
+
209
+ 1. **Add the marketplaces and install the plugins**, suwagent first.
210
+ - A person, in a Claude Code session: `/plugin marketplace add Manomenu/suwalski-agent-plugin`, `/plugin install suwagent@suwalski-agent-plugin`, then `/plugin marketplace add Manomenu/suwgate` and `/plugin install suwgate@suwgate`, choosing a scope each time.
211
+ - An agent, in a shell: `claude plugin marketplace add Manomenu/suwalski-agent-plugin`, `claude plugin install suwagent@suwalski-agent-plugin`, `claude plugin marketplace add Manomenu/suwgate`, then `claude plugin install suwgate@suwgate` (user scope; `--scope project` or `--scope local` to change it).
212
+ 2. **Turn on auto-update of both marketplaces.** It is off by default for a marketplace that is not Anthropic's.
213
+ - A person: `/plugin` > **Marketplaces** > each of `suwalski-agent-plugin` and `suwgate` > turn on auto-update.
214
+ - An agent: the documented non-interactive way is the key `autoUpdate` on the marketplace's entry in `extraKnownMarketplaces`, in a settings file. Step 1 already wrote both entries to `~/.claude/settings.json`; merge `"autoUpdate": true` into each and change nothing else in the file:
215
+ ```json
216
+ {
217
+ "extraKnownMarketplaces": {
218
+ "suwalski-agent-plugin": {
219
+ "source": { "source": "github", "repo": "Manomenu/suwalski-agent-plugin" },
220
+ "autoUpdate": true
221
+ },
222
+ "suwgate": {
223
+ "source": { "source": "github", "repo": "Manomenu/suwgate" },
224
+ "autoUpdate": true
225
+ }
226
+ }
227
+ }
228
+ ```
229
+ Claude Code docs, "Plugin loading reference", "When auto-update runs": whether a marketplace auto-updates follows `autoUpdate` on its `extraKnownMarketplaces` entry in a settings file, then the toggle under `/plugin` **Marketplaces**, then the default. Do not edit `~/.claude/plugins/known_marketplaces.json`: it is Claude Code's own record. If an entry is missing or the file is not plain JSON, ask the user to do the `/plugin` step instead.
230
+ 3. **Verify.** `claude plugin list` shows `suwagent@suwalski-agent-plugin` and `suwgate@suwgate`, each with `Status: enabled`. Then run `/reload-plugins` in the session (or start a new one) to load the skills.
231
+ 4. **Update by hand** with `/suwgate:update` (and `/suwagent:update` for suwagent), or `claude plugin update suwgate@suwgate`.
232
+
233
+ | Skill | Started by | What it does |
234
+ | :------------------------ | :--------------------- | :------------------------------------------------------------------------- |
235
+ | `suwgate` | the agent | every command of the CLI, the rules an agent keeps, how to read the output |
236
+ | `insights` | the agent | answers questions about the gate's state from `suwgate dashboard --json` |
237
+ | `/suwgate:dashboard` | you | starts the live dashboard in the background and gives the address |
238
+ | `/suwgate:dashboard-open` | you | the same, and opens it in your browser |
239
+ | `/suwgate:doctor` | you | runs `suwgate doctor` and reports each finding with its fix |
240
+ | `/suwgate:ship` | you, or a refused push | takes a finished change to a pull request (agent `shipper`) |
241
+ | `/suwgate:garden` | you or a schedule | the weekly run over documentation drift and the gate's own numbers |
242
+ | `/suwgate:update` | you | updates the plugin and checks it against the repository's suwgate |
243
+
244
+ The plugin has two agents, each with its own clean context. `/suwgate:ship` starts the simplifier on normal and careful changes only (a small change, documentation or configuration only or at most 50 changed lines of code with no spec and nothing careful, skips it and the review, and the hand-back says so). The review and the PR proof are the suwagent skills `/suwagent:agent-review` and `/suwagent:pr-proof`; `/suwgate:ship` stops before pushing, with one message, when they are needed and suwagent is not installed.
245
+
246
+ | Agent | Tools | What it does |
247
+ | :------------------- | :----------------------------- | :-------------------------------------------------------------------------------------------------------------- |
248
+ | `suwgate:shipper` | shell, files, `Agent`, `Skill` | takes the change to a pull request: `suwgate ship`, push, CI, and starts the simplifier and the suwagent skills |
249
+ | `suwgate:simplifier` | shell, files | makes the change simpler without changing its behaviour; commits it, never pushes |
250
+
251
+ The plugin describes suwgate 0.17.0; a repository on an older package lacks `stats`, `doctor`, `dashboard` and `garden-ran`, and the skills say so instead of working around it.
252
+
167
253
  ## Configuration
168
254
 
169
255
  <picture>
package/dist/cli.js CHANGED
@@ -1,23 +1,34 @@
1
1
  #!/usr/bin/env node
2
- import { readFileSync } from "node:fs";
2
+ import { readdirSync, readFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import path from "node:path";
3
5
  import { parseArgs } from "node:util";
4
6
  import { check, step } from "./gate/check.js";
5
7
  import { dev, realEnvironment } from "./dev/index.js";
6
8
  import { Failure } from "./dev/process.js";
7
9
  import { loadConfig } from "./gate/config.js";
8
10
  import { allSteps } from "./gate/plan.js";
11
+ import { branchOf, inCommonDir, readRuns } from "./gate/history.js";
12
+ import { readContext } from "./gate/context.js";
13
+ import { dashboard, dashboardAsJson, GARDEN_FILE, liveSources } from "./gate/dashboardFile.js";
14
+ import { startDashboardServer } from "./gate/dashboardServer.js";
15
+ import { formatStats, summarize } from "./gate/stats.js";
9
16
  import { PROFILES } from "./gate/contract.js";
10
- import { changedFiles, repositoryRoot } from "./gate/repository.js";
17
+ import { changedFiles, repositoryFiles, repositoryRoot } from "./gate/repository.js";
18
+ import { criterionIds } from "./profiles/criteriaRan.js";
11
19
  import { guards, SHARED_RULES, writeSharedRules } from "./guards/index.js";
12
- import { discoverApiIn, dotnetGuards, stepsFor, verdict } from "./profiles/index.js";
20
+ import { discoverApiIn, dotnetGuards, holdoutStep, stepsFor, verdict } from "./profiles/index.js";
13
21
  import { readTimes, reportLocation } from "./profiles/reports.js";
22
+ import { doctor } from "./session/doctor.js";
23
+ import { lastGarden, parseFound, recordGarden } from "./session/gardenRecord.js";
24
+ import { findSuwagent } from "./session/suwagentInfo.js";
14
25
  import { guardPr } from "./session/guardPr.js";
15
26
  import { guardEdit } from "./session/guardEdit.js";
16
27
  import { preCommit, runTool } from "./session/preCommit.js";
17
28
  import { prePush } from "./session/prePush.js";
18
29
  import { ship } from "./session/ship.js";
19
30
  import { stop } from "./session/stop.js";
20
- const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verbose] [-- <args>]] | suwgate hook <guard-edit|guard-pr|stop|pre-commit|pre-push> | suwgate ship | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
31
+ const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [--only] [--verbose] [-- <args>]] | suwgate hook <guard-edit|guard-pr|stop|pre-commit|pre-push> | suwgate ship | suwgate stats [--days <n>] [--json] | suwgate doctor | suwgate context | suwgate dashboard [--days <n>] [--out <path> | --serve [--port <n>] | --json] | suwgate garden-ran <kind>=<count>... | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
21
32
  suwgate check every step of the repository's profiles (suwgate.yml) and the repository guards
22
33
  suwgate check --quick the guards, and the quick steps only for what changed since master; has a time budget
23
34
  (SUWGATE_QUICK_LIMIT seconds, default 20) because the Stop hook runs it after every turn
@@ -37,18 +48,46 @@ const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [
37
48
  suwgate hook pre-push git pre-push hook: refuses a push of a branch whose tree has no ship record
38
49
  suwgate ship needs a clean working tree: runs the quick gate and the e2e tests whose files changed on the
39
50
  branch, then records the tree (the pre-push and guard-pr hooks let a push of it through)
51
+ suwgate stats what the gate caught: runs and red share per mode, quick gate times and budget overruns, the slowest
52
+ steps, the guards by findings and the guards with none, from suwgate-runs.jsonl in the git common
53
+ directory (every run of check, ship, the Stop and pre-commit hooks appends a line there; step does not)
54
+ --days <n> the period (30 by default), --json the same numbers as one JSON object
55
+ suwgate doctor is the wall up: reads the rules and the branch protection of the main branch through gh and fails
56
+ when it needs no pull request, requires no status check or not the gate's, allows force pushes or
57
+ deletion, or when core.hooksPath and the hooks are not wired here; exit 2 when gh cannot answer
58
+ (not installed, not logged in, no GitHub remote); read-only, needs the network, never part of the gate
59
+ suwgate context a short plain-text map for an agent (at most 1,800 characters): how work reaches a pull request here,
60
+ the version, profiles, unwired hooks and the last run on this branch, where to look; local data only, no
61
+ network, no gate run; empty output without a valid suwgate.yml; the plugin's SessionStart hook prints it
62
+ suwgate dashboard one self-contained, read-only HTML page with the whole method of this repository: what needs the owner,
63
+ the wall (as suwgate doctor reads it), runs, what broke and on which branch, what the repository has,
64
+ which acceptance criteria have a test, the installed suwagent and the last cleaning; written to
65
+ suwgate-dashboard.html in the git common directory (--out <path> elsewhere), the path is printed;
66
+ --days <n> the period (30 by default); never runs the gate and never records a run; exit 2 on a bad suwgate.yml
67
+ suwgate dashboard --json
68
+ the data of the page as one JSON object on stdout (schemaVersion, attention, wall, runs, stopped,
69
+ branches, steps, guards, exceptions, hooks, quietGuards, criteria, plugin, garden, about), no file
70
+ suwgate dashboard --serve [--port <n>]
71
+ the same page live, at http://127.0.0.1:<port>/ (4780, else the next free port), for a browser tab kept
72
+ open beside the work: it follows new runs, cleaning traces and changes of suwgate.yml within seconds and
73
+ keeps the opened parts open; answers only this machine, asks GitHub for the wall at most every 5 minutes,
74
+ writes nothing; runs until interrupted, so start it in the background suwgate garden-ran <kind>=<count> ...
75
+ records a cleaning run (e.g. suwgate garden-ran docs=3 guards=2) as one line of suwgate-garden.jsonl in the
76
+ git common directory, which suwgate dashboard shows; a kind is a kebab-case word, a count a whole number
40
77
  suwgate dev <db|logs|smoke|server|tmux|sibling|api-types|slow-tests|checkout-env>
41
78
  the local stack of the repository (the dev section of suwgate.yml), and the images of the
42
79
  sibling repositories it runs, rebuilt from their checkouts when stale, the API contract and types regenerated
43
80
  from the server, and a report of the slowest tests; suwgate dev --help
44
81
  suwgate agents-shared writes AGENTS.shared.md, the rules every repository shares, as this suwgate ships it, into the
45
82
  repository root (the agents-shared guard fails until the copy is current)
46
- suwgate verdict <tests|guards|tsconfig|eslint> ...
83
+ suwgate verdict <tests|holdout|guards|tsconfig|eslint> ...
47
84
  what the steps call after their tool: did tests run, did the .NET guards run (evidence),
48
- are the strict compiler options and the eslint rules in effect
85
+ are the strict compiler options and the eslint rules in effect, which holdout scenarios failed
49
86
  Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step whose tool is missing is SKIP,
50
87
  and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.`;
51
- const catalog = { guards, dotnetGuards, stepsFor };
88
+ const DEFAULT_PORT = 4780;
89
+ const PORT_FALLBACKS = 20;
90
+ const catalog = { guards, dotnetGuards, stepsFor, holdoutStep };
52
91
  function version() {
53
92
  const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
54
93
  return manifest.version;
@@ -93,6 +132,42 @@ function readInput() {
93
132
  return "";
94
133
  }
95
134
  }
135
+ async function runDoctor(root) {
136
+ const hooksGuard = guards.find((guard) => guard.id === "hooks");
137
+ return await doctor(root, runTool, {
138
+ hookFindings: async () => {
139
+ if (hooksGuard === undefined)
140
+ return [];
141
+ return await hooksGuard.check({
142
+ root,
143
+ files: repositoryFiles(root),
144
+ profiles: PROFILES,
145
+ directories: {},
146
+ exceptions: [],
147
+ settings: undefined,
148
+ read: (file) => readFileSync(path.join(root, file), "utf8"),
149
+ });
150
+ },
151
+ });
152
+ }
153
+ const pluginFiles = {
154
+ read: (file) => {
155
+ try {
156
+ return readFileSync(file, "utf8");
157
+ }
158
+ catch {
159
+ return null;
160
+ }
161
+ },
162
+ list: (folder) => {
163
+ try {
164
+ return readdirSync(folder);
165
+ }
166
+ catch {
167
+ return [];
168
+ }
169
+ },
170
+ };
96
171
  async function runStep(argv) {
97
172
  const separator = argv.indexOf("--");
98
173
  const own = separator === -1 ? argv : argv.slice(0, separator);
@@ -136,7 +211,17 @@ async function main(argv) {
136
211
  args: [...argv],
137
212
  allowPositionals: true,
138
213
  strict: true,
139
- options: { quick: { type: "boolean" }, verbose: { type: "boolean" }, help: { type: "boolean" }, version: { type: "boolean" } },
214
+ options: {
215
+ quick: { type: "boolean" },
216
+ verbose: { type: "boolean" },
217
+ help: { type: "boolean" },
218
+ version: { type: "boolean" },
219
+ days: { type: "string" },
220
+ json: { type: "boolean" },
221
+ out: { type: "string" },
222
+ serve: { type: "boolean" },
223
+ port: { type: "string" },
224
+ },
140
225
  });
141
226
  const [command, hook, ...rest] = positionals;
142
227
  if (values.help === true) {
@@ -147,7 +232,118 @@ async function main(argv) {
147
232
  console.log(version());
148
233
  return 0;
149
234
  }
150
- const runCheck = (cwd, quick, verbose) => check({ cwd, quick, verbose, env: process.env, catalog });
235
+ const runCheck = (cwd, quick, verbose, label = {}) => check({ cwd, quick, verbose, env: process.env, catalog, ...label });
236
+ if (command === "doctor" && hook === undefined) {
237
+ const verdict = await runDoctor(repositoryRoot(process.cwd()) ?? process.cwd());
238
+ (verdict.exitCode === 0 ? console.log : console.error)(verdict.text);
239
+ return verdict.exitCode;
240
+ }
241
+ if (command === "context" && hook === undefined) {
242
+ const text = readContext({
243
+ cwd: process.cwd(),
244
+ days: 30,
245
+ out: undefined,
246
+ now: () => new Date(),
247
+ catalog,
248
+ extraFiles: [],
249
+ wall: () => Promise.resolve([]),
250
+ criterionIds,
251
+ plugin: () => null,
252
+ garden: () => null,
253
+ }, version(), process.argv[1] ?? "");
254
+ if (text !== "")
255
+ console.log(text.trimEnd());
256
+ return 0;
257
+ }
258
+ if (command === "dashboard" && hook === undefined) {
259
+ const days = values.days === undefined ? 30 : Number(values.days);
260
+ if (!Number.isInteger(days) || days < 1) {
261
+ console.error(`suwgate dashboard: --days takes a whole number of days, not '${values.days}': pass e.g. --days 30`);
262
+ return 2;
263
+ }
264
+ const port = values.port === undefined ? DEFAULT_PORT : Number(values.port);
265
+ if (!Number.isInteger(port) || port < 0 || port > 65_535 || (values.port !== undefined && values.serve !== true)) {
266
+ console.error(`suwgate dashboard: --port takes a port number and only with --serve, not '${values.port}': pass e.g. --serve --port ${DEFAULT_PORT}`);
267
+ return 2;
268
+ }
269
+ if (values.json === true && (values.serve === true || values.out !== undefined)) {
270
+ console.error("suwgate dashboard: --json prints the data and writes no file, so it takes neither --serve nor --out");
271
+ return 2;
272
+ }
273
+ if (values.serve === true && values.out !== undefined) {
274
+ console.error("suwgate dashboard: --serve writes no file, so --out has no meaning with it");
275
+ return 2;
276
+ }
277
+ const configDir = process.env["CLAUDE_CONFIG_DIR"] ?? path.join(homedir(), ".claude");
278
+ const request = {
279
+ cwd: process.cwd(),
280
+ days,
281
+ out: values.out,
282
+ now: () => new Date(),
283
+ catalog,
284
+ extraFiles: [path.join(configDir, "plugins", "installed_plugins.json")],
285
+ wall: async (root) => (await runDoctor(root)).checks,
286
+ criterionIds,
287
+ plugin: (root) => findSuwagent(configDir, root, pluginFiles),
288
+ garden: lastGarden,
289
+ };
290
+ if (values.serve !== true) {
291
+ const result = await (values.json === true ? dashboardAsJson : dashboard)(request);
292
+ (result.exitCode === 0 ? console.log : console.error)(result.text);
293
+ return result.exitCode;
294
+ }
295
+ const sources = liveSources(request);
296
+ if ("exitCode" in sources) {
297
+ console.error(sources.text);
298
+ return sources.exitCode;
299
+ }
300
+ let server;
301
+ try {
302
+ server = await startDashboardServer({ port, fallbacks: PORT_FALLBACKS, ...sources });
303
+ }
304
+ catch (error) {
305
+ console.error(error instanceof Error ? error.message : String(error));
306
+ return 1;
307
+ }
308
+ console.log(`http://127.0.0.1:${server.port}/`);
309
+ await new Promise((resolve) => {
310
+ process.once("SIGINT", resolve);
311
+ process.once("SIGTERM", resolve);
312
+ });
313
+ await server.close();
314
+ return 0;
315
+ }
316
+ if (command === "garden-ran") {
317
+ const parsed = parseFound(positionals.slice(1));
318
+ if ("problem" in parsed) {
319
+ console.error(parsed.problem);
320
+ return 2;
321
+ }
322
+ const root = repositoryRoot(process.cwd());
323
+ const file = root === null ? null : inCommonDir(root, GARDEN_FILE);
324
+ if (root === null || file === null) {
325
+ console.error(`suwgate garden-ran: ${process.cwd()} is not inside a git repository: run it in a checkout`);
326
+ return 2;
327
+ }
328
+ recordGarden(file, { at: new Date().toISOString(), branch: branchOf(root), found: parsed.found });
329
+ console.log(`recorded a cleaning run in ${file}`);
330
+ return 0;
331
+ }
332
+ if (command === "stats" && hook === undefined) {
333
+ const days = values.days === undefined ? 30 : Number(values.days);
334
+ if (!Number.isInteger(days) || days < 1) {
335
+ console.error(`suwgate stats: --days takes a whole number of days, not '${values.days}': pass e.g. --days 30`);
336
+ return 2;
337
+ }
338
+ const root = repositoryRoot(process.cwd());
339
+ if (root === null) {
340
+ console.error(`suwgate stats: ${process.cwd()} is not inside a git repository: run it in a checkout`);
341
+ return 2;
342
+ }
343
+ const stats = summarize(readRuns(root), days, new Date());
344
+ console.log(values.json === true ? JSON.stringify(stats) : formatStats(stats));
345
+ return 0;
346
+ }
151
347
  if (command === "check" && hook === undefined) {
152
348
  const result = await runCheck(process.cwd(), values.quick === true, values.verbose === true);
153
349
  (result.exitCode === 0 ? console.log : console.error)(result.text);
@@ -161,7 +357,7 @@ async function main(argv) {
161
357
  }
162
358
  if (command === "hook" && rest.length === 0 && hook === "pre-commit") {
163
359
  const root = repositoryRoot(process.cwd()) ?? process.cwd();
164
- const verdict = await preCommit(root, runTool, () => runCheck(root, true, false));
360
+ const verdict = await preCommit(root, runTool, () => runCheck(root, true, false, { source: "pre-commit" }));
165
361
  if (verdict.message !== "")
166
362
  console.error(verdict.message);
167
363
  return verdict.exitCode;
@@ -170,7 +366,7 @@ async function main(argv) {
170
366
  const root = repositoryRoot(process.cwd()) ?? process.cwd();
171
367
  const verdict = await ship(root, {
172
368
  changedFiles: () => changedFiles(root),
173
- quickCheck: () => runCheck(root, true, false),
369
+ quickCheck: () => runCheck(root, true, false, { mode: "ship" }),
174
370
  e2e: (files) => step({ cwd: root, id: "e2e", only: false, args: files, verbose: false, env: process.env, catalog }),
175
371
  });
176
372
  (verdict.exitCode === 0 ? console.log : console.error)(verdict.message);
@@ -194,7 +390,7 @@ async function main(argv) {
194
390
  const root = process.env["CLAUDE_PROJECT_DIR"] ?? repositoryRoot(process.cwd()) ?? process.cwd();
195
391
  const verdict = hook === "guard-edit"
196
392
  ? guardEdit(readInput(), editHookProject(root), process.env["ALLOW_GATE_EDIT"] === "1")
197
- : await stop(readInput(), root, () => runCheck(root, true, false));
393
+ : await stop(readInput(), root, () => runCheck(root, true, false, { source: "stop" }));
198
394
  if (verdict.message !== "")
199
395
  console.error(verdict.message);
200
396
  return verdict.exitCode;
@@ -6,6 +6,7 @@ export interface StrictOptions {
6
6
  projects?: readonly string[];
7
7
  ignores?: readonly string[];
8
8
  untyped?: readonly string[];
9
+ tailwindEntryPoint?: string;
9
10
  }
10
11
  export interface AppOptions extends StrictOptions {
11
12
  features: readonly string[];
@@ -1,6 +1,8 @@
1
+ import { existsSync } from "node:fs";
1
2
  import path from "node:path";
2
3
  import js from "@eslint/js";
3
4
  import { defineConfig, globalIgnores } from "eslint/config";
5
+ import betterTailwindcss from "eslint-plugin-better-tailwindcss";
4
6
  import boundaries from "eslint-plugin-boundaries";
5
7
  import tseslint from "typescript-eslint";
6
8
  import { noComments } from "./noComments.js";
@@ -8,6 +10,7 @@ export { noComments };
8
10
  const BOUNDARIES_PLUGIN = boundaries;
9
11
  const CODE = ["**/*.{ts,tsx,js,jsx,mjs,cjs,mts,cts}"];
10
12
  const SOURCES = ["src/**/*.{ts,tsx}"];
13
+ const TAILWIND_ENTRY_POINT = "src/index.css";
11
14
  const BROWSER_STORAGE = ["localStorage", "sessionStorage", "indexedDB"];
12
15
  const BROWSER_STORAGE_FIX = "Keep the state on the server, in the address or in React; browser storage is allowed only in the files that storage of app() names in eslint.config.js.";
13
16
  const BOUNDARIES_FIX = "A feature of src/ imports only itself and the shared folders, a shared folder only itself (and the shared folders sharedImports of app() lets it), a file directly in src/ anything; a new folder of src/ goes into features or shared of app() in eslint.config.js.";
@@ -15,6 +18,22 @@ export const plugin = {
15
18
  meta: { name: "@maniumek/suwgate" },
16
19
  rules: { "no-comments": noComments },
17
20
  };
21
+ function unknownTailwindClasses(options) {
22
+ const entryPoint = path.resolve(options.root, options.tailwindEntryPoint ?? TAILWIND_ENTRY_POINT);
23
+ if (!existsSync(entryPoint)) {
24
+ if (options.tailwindEntryPoint === undefined)
25
+ return [];
26
+ throw new Error(`tailwindEntryPoint of strict() or app() in eslint.config.js names ${entryPoint}, which does not exist: name the CSS file that imports tailwindcss, relative to root`);
27
+ }
28
+ return [
29
+ {
30
+ files: CODE,
31
+ plugins: { "better-tailwindcss": betterTailwindcss },
32
+ settings: { "better-tailwindcss": { cwd: options.root, entryPoint } },
33
+ rules: { "better-tailwindcss/no-unknown-classes": "error" },
34
+ },
35
+ ];
36
+ }
18
37
  export function strict(options) {
19
38
  return defineConfig(globalIgnores(["dist", ".artifacts", ...(options.ignores ?? [])]), js.configs.recommended, tseslint.configs.strictTypeChecked, tseslint.configs.stylisticTypeChecked, {
20
39
  linterOptions: { noInlineConfig: true },
@@ -30,7 +49,7 @@ export function strict(options) {
30
49
  files: CODE,
31
50
  plugins: { suwgate: plugin },
32
51
  rules: { "suwgate/no-comments": "error" },
33
- }, {
52
+ }, unknownTailwindClasses(options), {
34
53
  files: ["eslint.config.js", ...(options.untyped ?? [])],
35
54
  extends: [tseslint.configs.disableTypeChecked],
36
55
  });
@@ -0,0 +1,38 @@
1
+ import type { RunRecord } from "./history.ts";
2
+ export interface Stopper {
3
+ kind: "guard" | "step";
4
+ id: string;
5
+ runs: number;
6
+ last: string;
7
+ branches: string[];
8
+ }
9
+ export interface BranchSummary {
10
+ branch: string;
11
+ runs: number;
12
+ red: number;
13
+ lastRed: {
14
+ at: string;
15
+ cause: string;
16
+ } | null;
17
+ }
18
+ export interface TrendPoint {
19
+ now: number | null;
20
+ before: number | null;
21
+ buckets: number[];
22
+ }
23
+ export interface Trends {
24
+ redShare: TrendPoint;
25
+ quickMedian: TrendPoint;
26
+ overBudget: TrendPoint;
27
+ }
28
+ export interface DayCount {
29
+ day: string;
30
+ runs: number;
31
+ red: number;
32
+ }
33
+ export declare function runsInPeriod(history: readonly RunRecord[], days: number, now: Date): RunRecord[];
34
+ export declare function stoppers(history: readonly RunRecord[], days: number, now: Date): Stopper[];
35
+ export declare function causeOf(run: RunRecord): string;
36
+ export declare function branches(history: readonly RunRecord[], days: number, now: Date): BranchSummary[];
37
+ export declare function trends(history: readonly RunRecord[], days: number, now: Date): Trends;
38
+ export declare function runsPerDay(history: readonly RunRecord[], days: number, now: Date): DayCount[];