@maniumek/suwgate 0.16.0 → 0.18.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/AGENTS.shared.md +13 -2
- package/README.md +98 -9
- package/dist/cli.js +217 -13
- package/dist/gate/breakdown.d.ts +40 -0
- package/dist/gate/breakdown.js +111 -0
- package/dist/gate/check.d.ts +4 -0
- package/dist/gate/check.js +38 -1
- package/dist/gate/ciHistory.d.ts +21 -0
- package/dist/gate/ciHistory.js +195 -0
- package/dist/gate/config.d.ts +5 -1
- package/dist/gate/config.js +56 -2
- package/dist/gate/context.d.ts +15 -0
- package/dist/gate/context.js +98 -0
- package/dist/gate/contract.d.ts +7 -0
- package/dist/gate/contract.js +1 -0
- package/dist/gate/dashboard.d.ts +112 -0
- package/dist/gate/dashboard.js +148 -0
- package/dist/gate/dashboardFile.d.ts +33 -0
- package/dist/gate/dashboardFile.js +185 -0
- package/dist/gate/dashboardJson.d.ts +2 -0
- package/dist/gate/dashboardJson.js +26 -0
- package/dist/gate/dashboardPage.d.ts +3 -0
- package/dist/gate/dashboardPage.js +307 -0
- package/dist/gate/dashboardServer.d.ts +11 -0
- package/dist/gate/dashboardServer.js +70 -0
- package/dist/gate/dashboardTesting.d.ts +12 -0
- package/dist/gate/dashboardTesting.js +99 -0
- package/dist/gate/guardsStep.d.ts +6 -0
- package/dist/gate/guardsStep.js +8 -1
- package/dist/gate/history.d.ts +31 -0
- package/dist/gate/history.js +105 -0
- package/dist/gate/plan.d.ts +3 -1
- package/dist/gate/plan.js +6 -3
- package/dist/gate/repository.d.ts +1 -0
- package/dist/gate/repository.js +1 -1
- package/dist/gate/runner.d.ts +3 -0
- package/dist/gate/runner.js +4 -1
- package/dist/gate/stats.d.ts +27 -0
- package/dist/gate/stats.js +84 -0
- package/dist/guards/comments/eslint.js +1 -0
- package/dist/guards/comments/scan.js +1 -0
- package/dist/guards/comments/switches.js +1 -0
- package/dist/guards/database/connectionHost.js +1 -0
- package/dist/guards/dotnet/appsettingsBound.js +1 -0
- package/dist/guards/dotnet/bannedNugetPackages.js +1 -0
- package/dist/guards/dotnet/openApiVersions.js +1 -0
- package/dist/guards/dotnet/suwbackkitWiring.js +1 -0
- package/dist/guards/dotnet/unusedNugetVersions.js +1 -0
- package/dist/guards/repository/bannedNpmPackages.js +1 -0
- package/dist/guards/repository/composePorts.js +1 -0
- package/dist/guards/repository/dependencyDirection.js +1 -0
- package/dist/guards/repository/forbiddenNames.js +1 -0
- package/dist/guards/repository/humanDocs.js +1 -0
- package/dist/guards/repository/imagePins.js +1 -0
- package/dist/guards/repository/justModules.js +1 -0
- package/dist/guards/repository/noRawColors.js +1 -0
- package/dist/guards/repository/repositoryLayout.js +1 -0
- package/dist/guards/repository/scriptsCalled.js +1 -0
- package/dist/guards/repository/scriptsHelp.js +1 -0
- package/dist/guards/repository/suwfrontkitWiring.js +1 -0
- package/dist/guards/repository/vsCodeSettings.js +1 -0
- package/dist/profiles/holdout.d.ts +2 -0
- package/dist/profiles/holdout.js +38 -0
- package/dist/profiles/index.d.ts +1 -0
- package/dist/profiles/index.js +1 -0
- package/dist/profiles/reports.d.ts +6 -0
- package/dist/profiles/reports.js +14 -0
- package/dist/profiles/verdict.js +41 -2
- package/dist/session/doctor.d.ts +26 -0
- package/dist/session/doctor.js +265 -0
- package/dist/session/gardenRecord.d.ts +12 -0
- package/dist/session/gardenRecord.js +58 -0
- package/dist/session/guardPr.js +2 -2
- package/dist/session/prePush.js +1 -1
- package/dist/session/suwagentInfo.d.ts +28 -0
- package/dist/session/suwagentInfo.js +103 -0
- package/package.json +1 -1
- 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? `/
|
|
17
|
-
|
|
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
|
+
<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
|
|
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
|
|
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>] [--no-ci] [--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,109 @@ 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, step, the Stop and pre-commit hooks appends a line there)
|
|
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, 90 at most); never runs the gate and never records a run; exit 2 on a
|
|
176
|
+
bad suwgate.yml; the runs are this machine's and CI's: each call asks GitHub (gh) only for the gate-history
|
|
177
|
+
artifacts newer than the last one it read, keeps them 90 days in the git common directory and says in the
|
|
178
|
+
page's first line up to when CI was read, or why it was not; --no-ci reads this machine only
|
|
179
|
+
suwgate dashboard --json
|
|
180
|
+
the data of the page as one JSON object on stdout (schemaVersion, attention, ci, wall, runs, stopped,
|
|
181
|
+
branches, steps, guards, exceptions, hooks, quietGuards, criteria, plugin, garden, about), no file
|
|
182
|
+
suwgate dashboard --serve [--port <n>]
|
|
183
|
+
the same page live, at http://127.0.0.1:<port>/ (4780, else the next free port), for a browser tab kept
|
|
184
|
+
open beside the work: it follows new runs, cleaning traces and changes of suwgate.yml within seconds and
|
|
185
|
+
keeps the opened parts open; answers only this machine, asks GitHub for the wall and for new runs of CI at
|
|
186
|
+
most every 5 minutes, writes only the runs of CI it read; runs until interrupted, so start it in the background suwgate garden-ran <kind>=<count> ...
|
|
187
|
+
records a cleaning run (e.g. suwgate garden-ran docs=3 guards=2) as one line of suwgate-garden.jsonl in the
|
|
188
|
+
git common directory, which suwgate dashboard shows; a kind is a kebab-case word, a count a whole number
|
|
152
189
|
suwgate dev <db|logs|smoke|server|tmux|sibling|api-types|slow-tests|checkout-env>
|
|
153
190
|
the local stack of the repository (the dev section of suwgate.yml), and the images of the
|
|
154
191
|
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
|
|
192
|
+
from the server, and a report of the slowest tests; suwgate dev --help
|
|
156
193
|
suwgate agents-shared writes AGENTS.shared.md, the rules every repository shares, as this suwgate ships it, into the
|
|
157
194
|
repository root (the agents-shared guard fails until the copy is current)
|
|
158
|
-
suwgate verdict <tests|guards|tsconfig|eslint> ...
|
|
195
|
+
suwgate verdict <tests|holdout|guards|tsconfig|eslint> ...
|
|
159
196
|
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
|
|
197
|
+
are the strict compiler options and the eslint rules in effect, which holdout scenarios failed
|
|
161
198
|
Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step whose tool is missing is SKIP,
|
|
162
199
|
and a SKIP fails the gate when CI is set. Exit code: 0 green, 1 red, 2 a usage or suwgate.yml problem.
|
|
163
200
|
```
|
|
164
201
|
|
|
165
202
|
</details>
|
|
166
203
|
|
|
204
|
+
## Claude Code plugin
|
|
205
|
+
|
|
206
|
+
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.
|
|
207
|
+
|
|
208
|
+
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.
|
|
209
|
+
|
|
210
|
+
Follow these steps in order; each has the form a person types in a session and the form an agent runs in a shell.
|
|
211
|
+
|
|
212
|
+
1. **Add the marketplaces and install the plugins**, suwagent first.
|
|
213
|
+
- 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.
|
|
214
|
+
- 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).
|
|
215
|
+
2. **Turn on auto-update of both marketplaces.** It is off by default for a marketplace that is not Anthropic's.
|
|
216
|
+
- A person: `/plugin` > **Marketplaces** > each of `suwalski-agent-plugin` and `suwgate` > turn on auto-update.
|
|
217
|
+
- 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:
|
|
218
|
+
```json
|
|
219
|
+
{
|
|
220
|
+
"extraKnownMarketplaces": {
|
|
221
|
+
"suwalski-agent-plugin": {
|
|
222
|
+
"source": { "source": "github", "repo": "Manomenu/suwalski-agent-plugin" },
|
|
223
|
+
"autoUpdate": true
|
|
224
|
+
},
|
|
225
|
+
"suwgate": {
|
|
226
|
+
"source": { "source": "github", "repo": "Manomenu/suwgate" },
|
|
227
|
+
"autoUpdate": true
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
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.
|
|
233
|
+
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.
|
|
234
|
+
4. **Update by hand** with `/suwgate:update` (and `/suwagent:update` for suwagent), or `claude plugin update suwgate@suwgate`.
|
|
235
|
+
|
|
236
|
+
| Skill | Started by | What it does |
|
|
237
|
+
| :------------------------ | :--------------------- | :------------------------------------------------------------------------- |
|
|
238
|
+
| `suwgate` | the agent | every command of the CLI, the rules an agent keeps, how to read the output |
|
|
239
|
+
| `insights` | the agent | answers questions about the gate's state from `suwgate dashboard --json` |
|
|
240
|
+
| `/suwgate:dashboard` | you | starts the live dashboard in the background and gives the address |
|
|
241
|
+
| `/suwgate:dashboard-open` | you | the same, and opens it in your browser |
|
|
242
|
+
| `/suwgate:doctor` | you | runs `suwgate doctor` and reports each finding with its fix |
|
|
243
|
+
| `/suwgate:ship` | you, or a refused push | takes a finished change to a pull request (agent `shipper`) |
|
|
244
|
+
| `/suwgate:garden` | you or a schedule | the weekly run over documentation drift and the gate's own numbers |
|
|
245
|
+
| `/suwgate:update` | you | updates the plugin and checks it against the repository's suwgate |
|
|
246
|
+
|
|
247
|
+
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.
|
|
248
|
+
|
|
249
|
+
| Agent | Tools | What it does |
|
|
250
|
+
| :------------------- | :----------------------------- | :-------------------------------------------------------------------------------------------------------------- |
|
|
251
|
+
| `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 |
|
|
252
|
+
| `suwgate:simplifier` | shell, files | makes the change simpler without changing its behaviour; commits it, never pushes |
|
|
253
|
+
|
|
254
|
+
The plugin describes suwgate 0.18.0; a repository on an older package lacks `stats`, `doctor`, `dashboard` and `garden-ran`, and the skills say so instead of working around it.
|
|
255
|
+
|
|
167
256
|
## Configuration
|
|
168
257
|
|
|
169
258
|
<picture>
|
package/dist/cli.js
CHANGED
|
@@ -1,23 +1,35 @@
|
|
|
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 { allRuns, RETENTION_DAYS, syncCi } from "./gate/ciHistory.js";
|
|
12
|
+
import { branchOf, inCommonDir } from "./gate/history.js";
|
|
13
|
+
import { readContext } from "./gate/context.js";
|
|
14
|
+
import { dashboard, dashboardAsJson, GARDEN_FILE, liveSources } from "./gate/dashboardFile.js";
|
|
15
|
+
import { startDashboardServer } from "./gate/dashboardServer.js";
|
|
16
|
+
import { formatStats, summarize } from "./gate/stats.js";
|
|
9
17
|
import { PROFILES } from "./gate/contract.js";
|
|
10
|
-
import { changedFiles, repositoryRoot } from "./gate/repository.js";
|
|
18
|
+
import { changedFiles, repositoryFiles, repositoryRoot } from "./gate/repository.js";
|
|
19
|
+
import { criterionIds } from "./profiles/criteriaRan.js";
|
|
11
20
|
import { guards, SHARED_RULES, writeSharedRules } from "./guards/index.js";
|
|
12
|
-
import { discoverApiIn, dotnetGuards, stepsFor, verdict } from "./profiles/index.js";
|
|
21
|
+
import { discoverApiIn, dotnetGuards, holdoutStep, stepsFor, verdict } from "./profiles/index.js";
|
|
13
22
|
import { readTimes, reportLocation } from "./profiles/reports.js";
|
|
23
|
+
import { doctor } from "./session/doctor.js";
|
|
24
|
+
import { lastGarden, parseFound, recordGarden } from "./session/gardenRecord.js";
|
|
25
|
+
import { findSuwagent } from "./session/suwagentInfo.js";
|
|
14
26
|
import { guardPr } from "./session/guardPr.js";
|
|
15
27
|
import { guardEdit } from "./session/guardEdit.js";
|
|
16
28
|
import { preCommit, runTool } from "./session/preCommit.js";
|
|
17
29
|
import { prePush } from "./session/prePush.js";
|
|
18
30
|
import { ship } from "./session/ship.js";
|
|
19
31
|
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
|
|
32
|
+
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>] [--no-ci] [--out <path> | --serve [--port <n>] | --json] | suwgate garden-ran <kind>=<count>... | suwgate dev <command> | suwgate agents-shared | suwgate --help | --version
|
|
21
33
|
suwgate check every step of the repository's profiles (suwgate.yml) and the repository guards
|
|
22
34
|
suwgate check --quick the guards, and the quick steps only for what changed since master; has a time budget
|
|
23
35
|
(SUWGATE_QUICK_LIMIT seconds, default 20) because the Stop hook runs it after every turn
|
|
@@ -37,18 +49,49 @@ const USAGE = `usage: suwgate check [--quick] [--verbose] | suwgate step [<id> [
|
|
|
37
49
|
suwgate hook pre-push git pre-push hook: refuses a push of a branch whose tree has no ship record
|
|
38
50
|
suwgate ship needs a clean working tree: runs the quick gate and the e2e tests whose files changed on the
|
|
39
51
|
branch, then records the tree (the pre-push and guard-pr hooks let a push of it through)
|
|
52
|
+
suwgate stats what the gate caught: runs and red share per mode, quick gate times and budget overruns, the slowest
|
|
53
|
+
steps, the guards by findings and the guards with none, from suwgate-runs.jsonl in the git common
|
|
54
|
+
directory (every run of check, ship, step, the Stop and pre-commit hooks appends a line there)
|
|
55
|
+
--days <n> the period (30 by default), --json the same numbers as one JSON object
|
|
56
|
+
suwgate doctor is the wall up: reads the rules and the branch protection of the main branch through gh and fails
|
|
57
|
+
when it needs no pull request, requires no status check or not the gate's, allows force pushes or
|
|
58
|
+
deletion, or when core.hooksPath and the hooks are not wired here; exit 2 when gh cannot answer
|
|
59
|
+
(not installed, not logged in, no GitHub remote); read-only, needs the network, never part of the gate
|
|
60
|
+
suwgate context a short plain-text map for an agent (at most 1,800 characters): how work reaches a pull request here,
|
|
61
|
+
the version, profiles, unwired hooks and the last run on this branch, where to look; local data only, no
|
|
62
|
+
network, no gate run; empty output without a valid suwgate.yml; the plugin's SessionStart hook prints it
|
|
63
|
+
suwgate dashboard one self-contained, read-only HTML page with the whole method of this repository: what needs the owner,
|
|
64
|
+
the wall (as suwgate doctor reads it), runs, what broke and on which branch, what the repository has,
|
|
65
|
+
which acceptance criteria have a test, the installed suwagent and the last cleaning; written to
|
|
66
|
+
suwgate-dashboard.html in the git common directory (--out <path> elsewhere), the path is printed;
|
|
67
|
+
--days <n> the period (30 by default, 90 at most); never runs the gate and never records a run; exit 2 on a
|
|
68
|
+
bad suwgate.yml; the runs are this machine's and CI's: each call asks GitHub (gh) only for the gate-history
|
|
69
|
+
artifacts newer than the last one it read, keeps them 90 days in the git common directory and says in the
|
|
70
|
+
page's first line up to when CI was read, or why it was not; --no-ci reads this machine only
|
|
71
|
+
suwgate dashboard --json
|
|
72
|
+
the data of the page as one JSON object on stdout (schemaVersion, attention, ci, wall, runs, stopped,
|
|
73
|
+
branches, steps, guards, exceptions, hooks, quietGuards, criteria, plugin, garden, about), no file
|
|
74
|
+
suwgate dashboard --serve [--port <n>]
|
|
75
|
+
the same page live, at http://127.0.0.1:<port>/ (4780, else the next free port), for a browser tab kept
|
|
76
|
+
open beside the work: it follows new runs, cleaning traces and changes of suwgate.yml within seconds and
|
|
77
|
+
keeps the opened parts open; answers only this machine, asks GitHub for the wall and for new runs of CI at
|
|
78
|
+
most every 5 minutes, writes only the runs of CI it read; runs until interrupted, so start it in the background suwgate garden-ran <kind>=<count> ...
|
|
79
|
+
records a cleaning run (e.g. suwgate garden-ran docs=3 guards=2) as one line of suwgate-garden.jsonl in the
|
|
80
|
+
git common directory, which suwgate dashboard shows; a kind is a kebab-case word, a count a whole number
|
|
40
81
|
suwgate dev <db|logs|smoke|server|tmux|sibling|api-types|slow-tests|checkout-env>
|
|
41
82
|
the local stack of the repository (the dev section of suwgate.yml), and the images of the
|
|
42
83
|
sibling repositories it runs, rebuilt from their checkouts when stale, the API contract and types regenerated
|
|
43
84
|
from the server, and a report of the slowest tests; suwgate dev --help
|
|
44
85
|
suwgate agents-shared writes AGENTS.shared.md, the rules every repository shares, as this suwgate ships it, into the
|
|
45
86
|
repository root (the agents-shared guard fails until the copy is current)
|
|
46
|
-
suwgate verdict <tests|guards|tsconfig|eslint> ...
|
|
87
|
+
suwgate verdict <tests|holdout|guards|tsconfig|eslint> ...
|
|
47
88
|
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
|
|
89
|
+
are the strict compiler options and the eslint rules in effect, which holdout scenarios failed
|
|
49
90
|
Every step has a ceiling (SUWGATE_STEP_LIMIT seconds overrides them all). A step whose tool is missing is SKIP,
|
|
50
91
|
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
|
|
92
|
+
const DEFAULT_PORT = 4780;
|
|
93
|
+
const PORT_FALLBACKS = 20;
|
|
94
|
+
const catalog = { guards, dotnetGuards, stepsFor, holdoutStep };
|
|
52
95
|
function version() {
|
|
53
96
|
const manifest = JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8"));
|
|
54
97
|
return manifest.version;
|
|
@@ -93,6 +136,42 @@ function readInput() {
|
|
|
93
136
|
return "";
|
|
94
137
|
}
|
|
95
138
|
}
|
|
139
|
+
async function runDoctor(root) {
|
|
140
|
+
const hooksGuard = guards.find((guard) => guard.id === "hooks");
|
|
141
|
+
return await doctor(root, runTool, {
|
|
142
|
+
hookFindings: async () => {
|
|
143
|
+
if (hooksGuard === undefined)
|
|
144
|
+
return [];
|
|
145
|
+
return await hooksGuard.check({
|
|
146
|
+
root,
|
|
147
|
+
files: repositoryFiles(root),
|
|
148
|
+
profiles: PROFILES,
|
|
149
|
+
directories: {},
|
|
150
|
+
exceptions: [],
|
|
151
|
+
settings: undefined,
|
|
152
|
+
read: (file) => readFileSync(path.join(root, file), "utf8"),
|
|
153
|
+
});
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
const pluginFiles = {
|
|
158
|
+
read: (file) => {
|
|
159
|
+
try {
|
|
160
|
+
return readFileSync(file, "utf8");
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
list: (folder) => {
|
|
167
|
+
try {
|
|
168
|
+
return readdirSync(folder);
|
|
169
|
+
}
|
|
170
|
+
catch {
|
|
171
|
+
return [];
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
};
|
|
96
175
|
async function runStep(argv) {
|
|
97
176
|
const separator = argv.indexOf("--");
|
|
98
177
|
const own = separator === -1 ? argv : argv.slice(0, separator);
|
|
@@ -113,6 +192,7 @@ async function runStep(argv) {
|
|
|
113
192
|
cwd: process.cwd(),
|
|
114
193
|
id: positionals[0],
|
|
115
194
|
only: values.only === true,
|
|
195
|
+
recordedAs: "step",
|
|
116
196
|
args,
|
|
117
197
|
verbose: values.verbose === true,
|
|
118
198
|
env: process.env,
|
|
@@ -136,7 +216,18 @@ async function main(argv) {
|
|
|
136
216
|
args: [...argv],
|
|
137
217
|
allowPositionals: true,
|
|
138
218
|
strict: true,
|
|
139
|
-
options: {
|
|
219
|
+
options: {
|
|
220
|
+
quick: { type: "boolean" },
|
|
221
|
+
verbose: { type: "boolean" },
|
|
222
|
+
help: { type: "boolean" },
|
|
223
|
+
version: { type: "boolean" },
|
|
224
|
+
days: { type: "string" },
|
|
225
|
+
json: { type: "boolean" },
|
|
226
|
+
"no-ci": { type: "boolean" },
|
|
227
|
+
out: { type: "string" },
|
|
228
|
+
serve: { type: "boolean" },
|
|
229
|
+
port: { type: "string" },
|
|
230
|
+
},
|
|
140
231
|
});
|
|
141
232
|
const [command, hook, ...rest] = positionals;
|
|
142
233
|
if (values.help === true) {
|
|
@@ -147,7 +238,120 @@ async function main(argv) {
|
|
|
147
238
|
console.log(version());
|
|
148
239
|
return 0;
|
|
149
240
|
}
|
|
150
|
-
const runCheck = (cwd, quick, verbose) => check({ cwd, quick, verbose, env: process.env, catalog });
|
|
241
|
+
const runCheck = (cwd, quick, verbose, label = {}) => check({ cwd, quick, verbose, env: process.env, catalog, ...label });
|
|
242
|
+
if (command === "doctor" && hook === undefined) {
|
|
243
|
+
const verdict = await runDoctor(repositoryRoot(process.cwd()) ?? process.cwd());
|
|
244
|
+
(verdict.exitCode === 0 ? console.log : console.error)(verdict.text);
|
|
245
|
+
return verdict.exitCode;
|
|
246
|
+
}
|
|
247
|
+
if (command === "context" && hook === undefined) {
|
|
248
|
+
const text = readContext({
|
|
249
|
+
cwd: process.cwd(),
|
|
250
|
+
days: 30,
|
|
251
|
+
out: undefined,
|
|
252
|
+
now: () => new Date(),
|
|
253
|
+
catalog,
|
|
254
|
+
extraFiles: [],
|
|
255
|
+
wall: () => Promise.resolve([]),
|
|
256
|
+
ci: () => Promise.resolve({ state: "off", syncedTo: null, reason: "" }),
|
|
257
|
+
criterionIds,
|
|
258
|
+
plugin: () => null,
|
|
259
|
+
garden: () => null,
|
|
260
|
+
}, version(), process.argv[1] ?? "");
|
|
261
|
+
if (text !== "")
|
|
262
|
+
console.log(text.trimEnd());
|
|
263
|
+
return 0;
|
|
264
|
+
}
|
|
265
|
+
if (command === "dashboard" && hook === undefined) {
|
|
266
|
+
const days = values.days === undefined ? 30 : Number(values.days);
|
|
267
|
+
if (!Number.isInteger(days) || days < 1 || days > RETENTION_DAYS) {
|
|
268
|
+
console.error(`suwgate dashboard: --days takes a whole number of days from 1 to ${RETENTION_DAYS}, not '${values.days}': pass e.g. --days 30`);
|
|
269
|
+
return 2;
|
|
270
|
+
}
|
|
271
|
+
const port = values.port === undefined ? DEFAULT_PORT : Number(values.port);
|
|
272
|
+
if (!Number.isInteger(port) || port < 0 || port > 65_535 || (values.port !== undefined && values.serve !== true)) {
|
|
273
|
+
console.error(`suwgate dashboard: --port takes a port number and only with --serve, not '${values.port}': pass e.g. --serve --port ${DEFAULT_PORT}`);
|
|
274
|
+
return 2;
|
|
275
|
+
}
|
|
276
|
+
if (values.json === true && (values.serve === true || values.out !== undefined)) {
|
|
277
|
+
console.error("suwgate dashboard: --json prints the data and writes no file, so it takes neither --serve nor --out");
|
|
278
|
+
return 2;
|
|
279
|
+
}
|
|
280
|
+
if (values.serve === true && values.out !== undefined) {
|
|
281
|
+
console.error("suwgate dashboard: --serve writes no file, so --out has no meaning with it");
|
|
282
|
+
return 2;
|
|
283
|
+
}
|
|
284
|
+
const configDir = process.env["CLAUDE_CONFIG_DIR"] ?? path.join(homedir(), ".claude");
|
|
285
|
+
const request = {
|
|
286
|
+
cwd: process.cwd(),
|
|
287
|
+
days,
|
|
288
|
+
out: values.out,
|
|
289
|
+
now: () => new Date(),
|
|
290
|
+
catalog,
|
|
291
|
+
extraFiles: [path.join(configDir, "plugins", "installed_plugins.json")],
|
|
292
|
+
wall: async (root) => (await runDoctor(root)).checks,
|
|
293
|
+
ci: (root, now) => values["no-ci"] === true ? Promise.resolve({ state: "off", syncedTo: null, reason: "" }) : syncCi(root, now),
|
|
294
|
+
criterionIds,
|
|
295
|
+
plugin: (root) => findSuwagent(configDir, root, pluginFiles),
|
|
296
|
+
garden: lastGarden,
|
|
297
|
+
};
|
|
298
|
+
if (values.serve !== true) {
|
|
299
|
+
const result = await (values.json === true ? dashboardAsJson : dashboard)(request);
|
|
300
|
+
(result.exitCode === 0 ? console.log : console.error)(result.text);
|
|
301
|
+
return result.exitCode;
|
|
302
|
+
}
|
|
303
|
+
const sources = liveSources(request);
|
|
304
|
+
if ("exitCode" in sources) {
|
|
305
|
+
console.error(sources.text);
|
|
306
|
+
return sources.exitCode;
|
|
307
|
+
}
|
|
308
|
+
let server;
|
|
309
|
+
try {
|
|
310
|
+
server = await startDashboardServer({ port, fallbacks: PORT_FALLBACKS, ...sources });
|
|
311
|
+
}
|
|
312
|
+
catch (error) {
|
|
313
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
314
|
+
return 1;
|
|
315
|
+
}
|
|
316
|
+
console.log(`http://127.0.0.1:${server.port}/`);
|
|
317
|
+
await new Promise((resolve) => {
|
|
318
|
+
process.once("SIGINT", resolve);
|
|
319
|
+
process.once("SIGTERM", resolve);
|
|
320
|
+
});
|
|
321
|
+
await server.close();
|
|
322
|
+
return 0;
|
|
323
|
+
}
|
|
324
|
+
if (command === "garden-ran") {
|
|
325
|
+
const parsed = parseFound(positionals.slice(1));
|
|
326
|
+
if ("problem" in parsed) {
|
|
327
|
+
console.error(parsed.problem);
|
|
328
|
+
return 2;
|
|
329
|
+
}
|
|
330
|
+
const root = repositoryRoot(process.cwd());
|
|
331
|
+
const file = root === null ? null : inCommonDir(root, GARDEN_FILE);
|
|
332
|
+
if (root === null || file === null) {
|
|
333
|
+
console.error(`suwgate garden-ran: ${process.cwd()} is not inside a git repository: run it in a checkout`);
|
|
334
|
+
return 2;
|
|
335
|
+
}
|
|
336
|
+
recordGarden(file, { at: new Date().toISOString(), branch: branchOf(root), found: parsed.found });
|
|
337
|
+
console.log(`recorded a cleaning run in ${file}`);
|
|
338
|
+
return 0;
|
|
339
|
+
}
|
|
340
|
+
if (command === "stats" && hook === undefined) {
|
|
341
|
+
const days = values.days === undefined ? 30 : Number(values.days);
|
|
342
|
+
if (!Number.isInteger(days) || days < 1) {
|
|
343
|
+
console.error(`suwgate stats: --days takes a whole number of days, not '${values.days}': pass e.g. --days 30`);
|
|
344
|
+
return 2;
|
|
345
|
+
}
|
|
346
|
+
const root = repositoryRoot(process.cwd());
|
|
347
|
+
if (root === null) {
|
|
348
|
+
console.error(`suwgate stats: ${process.cwd()} is not inside a git repository: run it in a checkout`);
|
|
349
|
+
return 2;
|
|
350
|
+
}
|
|
351
|
+
const stats = summarize(allRuns(root), days, new Date());
|
|
352
|
+
console.log(values.json === true ? JSON.stringify(stats) : formatStats(stats));
|
|
353
|
+
return 0;
|
|
354
|
+
}
|
|
151
355
|
if (command === "check" && hook === undefined) {
|
|
152
356
|
const result = await runCheck(process.cwd(), values.quick === true, values.verbose === true);
|
|
153
357
|
(result.exitCode === 0 ? console.log : console.error)(result.text);
|
|
@@ -161,7 +365,7 @@ async function main(argv) {
|
|
|
161
365
|
}
|
|
162
366
|
if (command === "hook" && rest.length === 0 && hook === "pre-commit") {
|
|
163
367
|
const root = repositoryRoot(process.cwd()) ?? process.cwd();
|
|
164
|
-
const verdict = await preCommit(root, runTool, () => runCheck(root, true, false));
|
|
368
|
+
const verdict = await preCommit(root, runTool, () => runCheck(root, true, false, { source: "pre-commit" }));
|
|
165
369
|
if (verdict.message !== "")
|
|
166
370
|
console.error(verdict.message);
|
|
167
371
|
return verdict.exitCode;
|
|
@@ -170,8 +374,8 @@ async function main(argv) {
|
|
|
170
374
|
const root = repositoryRoot(process.cwd()) ?? process.cwd();
|
|
171
375
|
const verdict = await ship(root, {
|
|
172
376
|
changedFiles: () => changedFiles(root),
|
|
173
|
-
quickCheck: () => runCheck(root, true, false),
|
|
174
|
-
e2e: (files) => step({ cwd: root, id: "e2e", only: false, args: files, verbose: false, env: process.env, catalog }),
|
|
377
|
+
quickCheck: () => runCheck(root, true, false, { mode: "ship" }),
|
|
378
|
+
e2e: (files) => step({ cwd: root, id: "e2e", only: false, args: files, verbose: false, recordedAs: "ship", env: process.env, catalog }),
|
|
175
379
|
});
|
|
176
380
|
(verdict.exitCode === 0 ? console.log : console.error)(verdict.message);
|
|
177
381
|
return verdict.exitCode;
|
|
@@ -194,7 +398,7 @@ async function main(argv) {
|
|
|
194
398
|
const root = process.env["CLAUDE_PROJECT_DIR"] ?? repositoryRoot(process.cwd()) ?? process.cwd();
|
|
195
399
|
const verdict = hook === "guard-edit"
|
|
196
400
|
? guardEdit(readInput(), editHookProject(root), process.env["ALLOW_GATE_EDIT"] === "1")
|
|
197
|
-
: await stop(readInput(), root, () => runCheck(root, true, false));
|
|
401
|
+
: await stop(readInput(), root, () => runCheck(root, true, false, { source: "stop" }));
|
|
198
402
|
if (verdict.message !== "")
|
|
199
403
|
console.error(verdict.message);
|
|
200
404
|
return verdict.exitCode;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RunRecord } from "./history.ts";
|
|
2
|
+
export interface Stopper {
|
|
3
|
+
kind: "guard" | "step";
|
|
4
|
+
id: string;
|
|
5
|
+
runs: number;
|
|
6
|
+
ci: number;
|
|
7
|
+
last: string;
|
|
8
|
+
branches: string[];
|
|
9
|
+
}
|
|
10
|
+
export interface BranchSummary {
|
|
11
|
+
branch: string;
|
|
12
|
+
runs: number;
|
|
13
|
+
ci: number;
|
|
14
|
+
red: number;
|
|
15
|
+
lastRed: {
|
|
16
|
+
at: string;
|
|
17
|
+
cause: string;
|
|
18
|
+
} | null;
|
|
19
|
+
}
|
|
20
|
+
export interface TrendPoint {
|
|
21
|
+
now: number | null;
|
|
22
|
+
before: number | null;
|
|
23
|
+
buckets: number[];
|
|
24
|
+
}
|
|
25
|
+
export interface Trends {
|
|
26
|
+
redShare: TrendPoint;
|
|
27
|
+
quickMedian: TrendPoint;
|
|
28
|
+
overBudget: TrendPoint;
|
|
29
|
+
}
|
|
30
|
+
export interface DayCount {
|
|
31
|
+
day: string;
|
|
32
|
+
runs: number;
|
|
33
|
+
red: number;
|
|
34
|
+
}
|
|
35
|
+
export declare function runsInPeriod(history: readonly RunRecord[], days: number, now: Date): RunRecord[];
|
|
36
|
+
export declare function stoppers(history: readonly RunRecord[], days: number, now: Date): Stopper[];
|
|
37
|
+
export declare function causeOf(run: RunRecord): string;
|
|
38
|
+
export declare function branches(history: readonly RunRecord[], days: number, now: Date): BranchSummary[];
|
|
39
|
+
export declare function trends(history: readonly RunRecord[], days: number, now: Date): Trends;
|
|
40
|
+
export declare function runsPerDay(history: readonly RunRecord[], days: number, now: Date): DayCount[];
|