sxh-quality-checks 0.1.1 → 0.2.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/LICENSE +21 -0
- package/README.md +174 -20
- package/dist/adapters/clock.d.ts +4 -0
- package/dist/adapters/clock.d.ts.map +1 -0
- package/dist/adapters/clock.js +3 -0
- package/dist/adapters/clock.js.map +1 -0
- package/dist/adapters/fs.d.ts +4 -0
- package/dist/adapters/fs.d.ts.map +1 -0
- package/dist/adapters/fs.js +49 -0
- package/dist/adapters/fs.js.map +1 -0
- package/dist/adapters/git.d.ts.map +1 -1
- package/dist/adapters/git.js +36 -2
- package/dist/adapters/git.js.map +1 -1
- package/dist/adapters/process.d.ts +7 -0
- package/dist/adapters/process.d.ts.map +1 -0
- package/dist/adapters/process.js +41 -0
- package/dist/adapters/process.js.map +1 -0
- package/dist/bin.js +6 -0
- package/dist/bin.js.map +1 -1
- package/dist/cli.d.ts +52 -4
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +548 -61
- package/dist/cli.js.map +1 -1
- package/dist/commit.d.ts +31 -0
- package/dist/commit.d.ts.map +1 -0
- package/dist/commit.js +103 -0
- package/dist/commit.js.map +1 -0
- package/dist/config.d.ts +1299 -28
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +170 -0
- package/dist/config.js.map +1 -1
- package/dist/decisions/changedLines.d.ts +111 -0
- package/dist/decisions/changedLines.d.ts.map +1 -0
- package/dist/decisions/changedLines.js +281 -0
- package/dist/decisions/changedLines.js.map +1 -0
- package/dist/decisions/fastPlan.d.ts +11 -0
- package/dist/decisions/fastPlan.d.ts.map +1 -0
- package/dist/decisions/fastPlan.js +61 -0
- package/dist/decisions/fastPlan.js.map +1 -0
- package/dist/decisions/planTier.d.ts +41 -0
- package/dist/decisions/planTier.d.ts.map +1 -0
- package/dist/decisions/planTier.js +63 -0
- package/dist/decisions/planTier.js.map +1 -0
- package/dist/index.d.ts +14 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -1
- package/dist/index.js.map +1 -1
- package/dist/lock.d.ts +42 -0
- package/dist/lock.d.ts.map +1 -0
- package/dist/lock.js +54 -0
- package/dist/lock.js.map +1 -0
- package/dist/newSource.d.ts +33 -0
- package/dist/newSource.d.ts.map +1 -0
- package/dist/newSource.js +79 -0
- package/dist/newSource.js.map +1 -0
- package/dist/ports.d.ts +40 -0
- package/dist/ports.d.ts.map +1 -1
- package/dist/ratchet.d.ts +53 -0
- package/dist/ratchet.d.ts.map +1 -0
- package/dist/ratchet.js +92 -0
- package/dist/ratchet.js.map +1 -0
- package/dist/receipt.d.ts +16 -0
- package/dist/receipt.d.ts.map +1 -0
- package/dist/receipt.js +14 -0
- package/dist/receipt.js.map +1 -0
- package/dist/testing/fs.d.ts +12 -0
- package/dist/testing/fs.d.ts.map +1 -0
- package/dist/testing/fs.js +25 -0
- package/dist/testing/fs.js.map +1 -0
- package/dist/testing/git.d.ts +10 -0
- package/dist/testing/git.d.ts.map +1 -1
- package/dist/testing/git.js +8 -0
- package/dist/testing/git.js.map +1 -1
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +2 -0
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/process.d.ts +15 -0
- package/dist/testing/process.d.ts.map +1 -0
- package/dist/testing/process.js +12 -0
- package/dist/testing/process.js.map +1 -0
- package/dist/version.d.ts +28 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +50 -0
- package/dist/version.js.map +1 -0
- package/package.json +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 sxh
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -23,29 +23,67 @@ temporary repositories the tests create.
|
|
|
23
23
|
## Usage
|
|
24
24
|
|
|
25
25
|
```sh
|
|
26
|
-
quality-checks
|
|
27
|
-
quality-checks
|
|
26
|
+
quality-checks run --dry-run # print the local gate's plan
|
|
27
|
+
quality-checks run # the local gate over the working diff
|
|
28
|
+
quality-checks run --fast scripts/gate.test.ts # preflight plus only the named tests
|
|
29
|
+
quality-checks tier commit # what the pre-commit hook runs
|
|
30
|
+
quality-checks tier push # what the pre-push hook runs
|
|
31
|
+
quality-checks tier message .git/COMMIT_EDITMSG # what the commit-msg hook runs
|
|
32
|
+
quality-checks lock acquire "tier push" # take the machine-wide gate lock
|
|
33
|
+
quality-checks lock release <pid> # drop the lock a run took
|
|
34
|
+
quality-checks receipt write # record the staged tree the tier passed
|
|
35
|
+
quality-checks receipt check # 0 when the staged tree already passed
|
|
36
|
+
quality-checks coverage changed-lines # judge the diff's changed lines
|
|
37
|
+
quality-checks coverage changed-lines --range origin/main
|
|
38
|
+
quality-checks ratchet # hold the lint warning count to its baseline
|
|
39
|
+
quality-checks commit -F message.txt --task T1 # close, stage, bump, judge, receipt, commit
|
|
40
|
+
quality-checks version bump # advance the app version and its constant
|
|
41
|
+
quality-checks new-source # refuse a new source file without its test
|
|
42
|
+
quality-checks suite select --cached --dry-run # print the suites the staged tree selects
|
|
43
|
+
quality-checks suite fast scripts/gate.test.ts # the inner-loop runner for named tests
|
|
28
44
|
```
|
|
29
45
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
34
|
-
|
|
|
35
|
-
|
|
|
36
|
-
|
|
|
37
|
-
| `
|
|
46
|
+
| Command | Judges | Config it uses |
|
|
47
|
+
| ------------------------ | -------------------------------------------------------- | ---------------------------------- |
|
|
48
|
+
| `run` | the working tree, or the paths given | `tiers.run` |
|
|
49
|
+
| `run --fast` | named test files only | `tiers.preflight` + `fast.runners` |
|
|
50
|
+
| `tier commit` | the staged tree (a commit in progress) | `tiers.commit` |
|
|
51
|
+
| `tier push` | the checkout | `tiers.push` |
|
|
52
|
+
| `tier message` | the commit message git handed the hook (`$1`) | `tiers.message` |
|
|
53
|
+
| `suite select` | the staged or working diff | `suites`, `fallback` |
|
|
54
|
+
| `suite fast` | named test files only | `fast.runners` |
|
|
55
|
+
| `lock` | one gate run at a time (0 taken, 3 refused, 4 nested) | — |
|
|
56
|
+
| `receipt` | the staged tree's commit-tier receipt | — |
|
|
57
|
+
| `coverage changed-lines` | statements that start on a line the diff adds or changes | `changedLines` |
|
|
58
|
+
| `ratchet` | the lint warning count against its baseline | `ratchet` |
|
|
59
|
+
| `commit` | close → stage → bump → tier → receipt → commit | `commit`, `version` |
|
|
60
|
+
| `version bump` | the version file and its generated constant | `version` |
|
|
61
|
+
| `new-source` | staged new source files and their tests | `newSource` |
|
|
38
62
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
63
|
+
Every tier ends with the same verdict line and the real exit code —
|
|
64
|
+
`gate: PASSED (0)` or `gate: FAILED (<code>)` — so a piped or truncated log
|
|
65
|
+
cannot turn a failure into a success.
|
|
66
|
+
|
|
67
|
+
The lock and the receipt live beside the git directory (`gate.lock`,
|
|
68
|
+
`gate-receipt`). The lock is keyed by pid: a lock whose holder is gone is
|
|
69
|
+
reclaimed automatically, and a run the holder itself started is treated as part
|
|
70
|
+
of the same gate. The receipt is keyed by `git write-tree`: any further staged
|
|
71
|
+
edit changes the hash, so a tree the tier has never seen cannot be skipped.
|
|
72
|
+
|
|
73
|
+
Common flags: `--dry-run` prints each step instead of running it; `--config`
|
|
74
|
+
selects another config file; `suite select` also takes `--cached`,
|
|
75
|
+
`--with-mutation` and `--coverage`.
|
|
76
|
+
|
|
77
|
+
`tier commit` takes the declared docs fast path when every staged path is
|
|
78
|
+
documentation or PCP state; `commit.docsOnly` is required in the config, so a
|
|
79
|
+
docs-only commit cannot silently run nothing.
|
|
42
80
|
|
|
43
81
|
## Config
|
|
44
82
|
|
|
45
83
|
```json
|
|
46
84
|
{
|
|
47
85
|
"docs": { "files": ["VERSION"], "dirs": ["docs/", ".opencode/pcp/"], "extensions": [".md"] },
|
|
48
|
-
"fallback": ["
|
|
86
|
+
"fallback": ["root"],
|
|
49
87
|
"suites": [
|
|
50
88
|
{
|
|
51
89
|
"name": "dart",
|
|
@@ -59,20 +97,136 @@ needs running.
|
|
|
59
97
|
"mutateCommand": ["bash", "scripts/mutate-changed.sh"],
|
|
60
98
|
"match": [{ "prefix": "packages/functions/" }]
|
|
61
99
|
}
|
|
62
|
-
]
|
|
100
|
+
],
|
|
101
|
+
"tiers": {
|
|
102
|
+
"run": [{ "lock": "hold" }, { "tier": "preflight" }, { "suites": { "mutation": true, "coverage": true } }],
|
|
103
|
+
"preflight": [{ "run": ["npm", "run", "format"] }, { "run": ["npm", "run", "lint"] }],
|
|
104
|
+
"commit": {
|
|
105
|
+
"steps": [{ "receipt": "check" }, { "run": ["bash", "scripts/preflight.sh"] }, { "suites": {} }],
|
|
106
|
+
"docsOnly": [{ "receipt": "check" }, { "tier": "preflight" }]
|
|
107
|
+
},
|
|
108
|
+
"push": [{ "lock": "hold" }, { "run": ["npm", "run", "test:all"] }],
|
|
109
|
+
"message": { "commands": [["bash", "scripts/check-pcp-task.sh"]] }
|
|
110
|
+
},
|
|
111
|
+
"fast": {
|
|
112
|
+
"runners": [
|
|
113
|
+
{ "command": ["npx", "vitest", "run"], "suffixes": [".test.ts", ".test.tsx"] },
|
|
114
|
+
{
|
|
115
|
+
"command": ["npx", "vitest", "run"],
|
|
116
|
+
"prefix": "packages/core/",
|
|
117
|
+
"cwd": "packages/core",
|
|
118
|
+
"suffixes": [".test.ts"]
|
|
119
|
+
}
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"changedLines": {
|
|
123
|
+
"sources": [
|
|
124
|
+
{
|
|
125
|
+
"pattern": "^packages/core/src/.*\\.ts$",
|
|
126
|
+
"report": "packages/core/coverage/coverage-final.json",
|
|
127
|
+
"format": "istanbul",
|
|
128
|
+
"suite": "npm test --workspace @rpg/core"
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
"pattern": "^packages/combat_app/lib/.*\\.dart$",
|
|
132
|
+
"report": "packages/combat_app/coverage/lcov.info",
|
|
133
|
+
"format": "lcov",
|
|
134
|
+
"prefix": "packages/combat_app/",
|
|
135
|
+
"suite": "bash scripts/cover.sh"
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"excludeFiles": ["index.ts", "main.dart"],
|
|
139
|
+
"excludePaths": ["scripts/spikes/"]
|
|
140
|
+
},
|
|
141
|
+
"ratchet": { "command": ["npx", "eslint", ".", "--format", "json"], "baseline": ".eslint-warning-count" },
|
|
142
|
+
"version": {
|
|
143
|
+
"file": "VERSION",
|
|
144
|
+
"generated": {
|
|
145
|
+
"path": "packages/combat_app/lib/app_version.dart",
|
|
146
|
+
"template": "// Generated from VERSION.\nconst appVersion = '{{version}}';\n"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
"newSource": {
|
|
150
|
+
"sources": [
|
|
151
|
+
{ "pattern": "^packages/[^/]+/src/.+\\.ts$", "test": "beside", "suffix": ".test.ts" },
|
|
152
|
+
{ "pattern": "^packages/[^/]+/lib/.+\\.dart$", "test": "package-test-dir", "suffix": "_test.dart" }
|
|
153
|
+
],
|
|
154
|
+
"excludeFiles": ["index.ts", "types.ts"]
|
|
155
|
+
},
|
|
156
|
+
"commit": {
|
|
157
|
+
"taskClose": {
|
|
158
|
+
"command": ["npx", "tsx", "scripts/close-pcp-task.ts"],
|
|
159
|
+
"trailer": "PCP-Task",
|
|
160
|
+
"stateFiles": [".opencode/pcp/stack.json", ".opencode/pcp/events.jsonl", ".opencode/pcp/WORKLOG.md"]
|
|
161
|
+
},
|
|
162
|
+
"requireHooksPath": "hooks"
|
|
163
|
+
}
|
|
63
164
|
}
|
|
64
165
|
```
|
|
65
166
|
|
|
66
167
|
`suites` is in run order. A `match` entry may name a `prefix` (with its trailing
|
|
67
168
|
slash), a `suffix`, or one exact `file`; every part present must match, and an
|
|
68
|
-
entry with none is rejected.
|
|
69
|
-
|
|
169
|
+
entry with none is rejected.
|
|
170
|
+
|
|
171
|
+
A tier step is exactly one of:
|
|
172
|
+
|
|
173
|
+
- `{ "run": ["cmd", "arg"] }` — a command;
|
|
174
|
+
- `{ "suites": { "mutation": bool, "coverage": bool } }` — the suites the diff
|
|
175
|
+
selects (both options default to false);
|
|
176
|
+
- `{ "tier": "preflight" }` — another tier's steps, inlined. A tier that
|
|
177
|
+
references itself, directly or through another, is rejected when planned;
|
|
178
|
+
- `{ "lock": "hold" }` — take the gate lock for the rest of the tier, released
|
|
179
|
+
when the tier ends. A dry run prints it without taking it;
|
|
180
|
+
- `{ "receipt": "check" }` — stop the tier successfully when the staged tree is
|
|
181
|
+
the one the commit tier already passed; `{ "receipt": "write" }` records it.
|
|
182
|
+
|
|
183
|
+
`fast.runners` plan the inner loop: each named test file belongs to the runner
|
|
184
|
+
with the longest matching `prefix`, must end in one of its `suffixes`, and runs
|
|
185
|
+
in its `cwd` (with the prefix stripped). A path no runner owns is an error, not
|
|
186
|
+
a skip.
|
|
187
|
+
|
|
188
|
+
`changedLines.sources` say which source each report judges: the pattern picks
|
|
189
|
+
the files, `report` names the report, `suite` names the command that rewrites
|
|
190
|
+
it. A changed statement (one that _starts_ on a line the diff adds or changes)
|
|
191
|
+
with zero hits fails the gate. A report older than the newest changed source it
|
|
192
|
+
would judge also fails — judging with it could pass an uncovered line as
|
|
193
|
+
covered. Only the additional exclusions the app needs belong in the config;
|
|
194
|
+
tests and generated declarations are excluded by the engine.
|
|
195
|
+
|
|
196
|
+
`ratchet` runs the app's lint command expecting JSON (`eslint . --format json`)
|
|
197
|
+
and holds the total warning count to the baseline file. Errors, or a count above
|
|
198
|
+
the baseline, fail; a lower count rewrites the baseline; there is no automatic
|
|
199
|
+
raise. A baseline that is not a count is a failure, not a reset.
|
|
70
200
|
|
|
71
|
-
|
|
201
|
+
`commit` is the whole commit in one command: close the task through the app's
|
|
202
|
+
configured adapter, stage the work, bump the version, run the commit tier,
|
|
203
|
+
record the receipt, then commit with the task trailer. On any failure the task
|
|
204
|
+
state files are restored, so the task stays open for the next attempt. With
|
|
205
|
+
`requireHooksPath` set, a checkout whose hooks are disabled is refused — the
|
|
206
|
+
commit would otherwise land unjudged.
|
|
72
207
|
|
|
73
|
-
|
|
208
|
+
`version` and `newSource` mirror the same discipline: a version that is not a
|
|
209
|
+
number fails rather than becoming `NaN`; a new source file whose test is not in
|
|
210
|
+
the same commit fails, naming the test it expected.
|
|
211
|
+
|
|
212
|
+
The config is validated on every read and every problem is named at once; each
|
|
213
|
+
object is strict, so a misspelt key is an error rather than a silent no-op.
|
|
214
|
+
|
|
215
|
+
## Hook shims
|
|
216
|
+
|
|
217
|
+
An app's hooks are three lines; the decisions live in the package:
|
|
218
|
+
|
|
219
|
+
```sh
|
|
220
|
+
#!/bin/sh
|
|
221
|
+
exec npx --no-install quality-checks tier commit
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
```sh
|
|
225
|
+
#!/bin/sh
|
|
226
|
+
exec npx --no-install quality-checks tier push
|
|
227
|
+
```
|
|
74
228
|
|
|
75
229
|
```sh
|
|
76
230
|
#!/bin/sh
|
|
77
|
-
exec npx --no-install quality-checks
|
|
231
|
+
exec npx --no-install quality-checks tier message "$1"
|
|
78
232
|
```
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.d.ts","sourceRoot":"","sources":["../../src/adapters/clock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,+EAA+E;AAC/E,eAAO,MAAM,WAAW,EAAE,SAA0C,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clock.js","sourceRoot":"","sources":["../../src/adapters/clock.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,MAAM,CAAC,MAAM,WAAW,GAAc,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../src/adapters/fs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASlD,2FAA2F;AAC3F,wBAAgB,oBAAoB,IAAI,cAAc,CAkCrD"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { readFileSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
2
|
+
const MISSING = "ENOENT";
|
|
3
|
+
const ALREADY_EXISTS = "EEXIST";
|
|
4
|
+
function codeOf(error) {
|
|
5
|
+
return error.code;
|
|
6
|
+
}
|
|
7
|
+
/** The real filesystem: absent files read as undefined, and exclusive create is atomic. */
|
|
8
|
+
export function createFileSystemPort() {
|
|
9
|
+
return {
|
|
10
|
+
read: (path) => {
|
|
11
|
+
try {
|
|
12
|
+
return readFileSync(path, "utf8");
|
|
13
|
+
}
|
|
14
|
+
catch (error) {
|
|
15
|
+
if (codeOf(error) === MISSING)
|
|
16
|
+
return undefined;
|
|
17
|
+
throw error;
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
write: (path, content) => {
|
|
21
|
+
writeFileSync(path, content);
|
|
22
|
+
},
|
|
23
|
+
createExclusive: (path, content) => {
|
|
24
|
+
try {
|
|
25
|
+
writeFileSync(path, content, { flag: "wx" });
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
catch (error) {
|
|
29
|
+
if (codeOf(error) === ALREADY_EXISTS)
|
|
30
|
+
return false;
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
remove: (path) => {
|
|
35
|
+
rmSync(path, { force: true });
|
|
36
|
+
},
|
|
37
|
+
mtime: (path) => {
|
|
38
|
+
try {
|
|
39
|
+
return statSync(path).mtimeMs;
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
if (codeOf(error) === MISSING)
|
|
43
|
+
return null;
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=fs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/adapters/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGxE,MAAM,OAAO,GAAG,QAAQ,CAAC;AACzB,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEhC,SAAS,MAAM,CAAC,KAAc;IAC1B,OAAQ,KAA+B,CAAC,IAAI,CAAC;AACjD,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,oBAAoB;IAChC,OAAO;QACH,IAAI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/git.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"git.d.ts","sourceRoot":"","sources":["../../src/adapters/git.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAe,MAAM,aAAa,CAAC;AAgBnE,4DAA4D;AAC5D,wBAAgB,cAAc,CAAC,MAAM,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,OAAO,GAAG,MAAM,CAM7E;AAED,sDAAsD;AACtD,wBAAgB,UAAU,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAMhH;AAED,MAAM,WAAW,cAAc;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,uEAAuE;IACvE,QAAQ,CAAC,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;IAC3D,iEAAiE;IACjE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC5B;AAED,uEAAuE;AACvE,wBAAgB,aAAa,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,cAAc,GAAG,OAAO,CAuDxF"}
|
package/dist/adapters/git.js
CHANGED
|
@@ -31,17 +31,51 @@ export function gitFreeEnv(env) {
|
|
|
31
31
|
}
|
|
32
32
|
/** The real git adapter: every command runs at the repository root. */
|
|
33
33
|
export function createGitPort({ repoRoot, spawn, env, gitPath }) {
|
|
34
|
-
const
|
|
34
|
+
const run = (args) => {
|
|
35
35
|
const result = spawn(gitPath, args, { cwd: repoRoot, env: gitFreeEnv(env) });
|
|
36
36
|
if (result.status !== 0) {
|
|
37
37
|
throw new Error(`git ${args.join(" ")} failed (${String(result.status)}): ${result.stderr.trim()}`);
|
|
38
38
|
}
|
|
39
|
-
return result
|
|
39
|
+
return result;
|
|
40
40
|
};
|
|
41
|
+
const lines = (args) => run(args)
|
|
42
|
+
.stdout.split("\n")
|
|
43
|
+
.filter((line) => line !== "");
|
|
41
44
|
return {
|
|
42
45
|
changedPaths: (mode) => mode === "staged"
|
|
43
46
|
? lines(["diff", "--cached", "--name-only", "-M"])
|
|
44
47
|
: [...lines(["diff", "--name-only", "HEAD"]), ...lines(["ls-files", "--others", "--exclude-standard"])],
|
|
48
|
+
gitDir: () => {
|
|
49
|
+
const [dir] = lines(["rev-parse", "--git-dir"]);
|
|
50
|
+
if (dir === undefined)
|
|
51
|
+
throw new Error("git rev-parse --git-dir returned no path");
|
|
52
|
+
return path.isAbsolute(dir) ? dir : path.join(repoRoot, dir);
|
|
53
|
+
},
|
|
54
|
+
writeTree: () => {
|
|
55
|
+
const [tree] = lines(["write-tree"]);
|
|
56
|
+
if (tree === undefined)
|
|
57
|
+
throw new Error("git write-tree returned no hash");
|
|
58
|
+
return tree;
|
|
59
|
+
},
|
|
60
|
+
output: (args) => run(args).stdout,
|
|
61
|
+
hooksPath: () => {
|
|
62
|
+
const result = spawn(gitPath, ["config", "core.hooksPath"], { cwd: repoRoot, env: gitFreeEnv(env) });
|
|
63
|
+
return result.status === 0 ? result.stdout.trim() : undefined;
|
|
64
|
+
},
|
|
65
|
+
hasStagedChanges: () => {
|
|
66
|
+
const result = spawn(gitPath, ["diff", "--cached", "--quiet"], { cwd: repoRoot, env: gitFreeEnv(env) });
|
|
67
|
+
return result.status !== 0;
|
|
68
|
+
},
|
|
69
|
+
stageAll: () => {
|
|
70
|
+
run(["add", "-A"]);
|
|
71
|
+
},
|
|
72
|
+
stage: (paths) => {
|
|
73
|
+
run(["add", "--", ...paths]);
|
|
74
|
+
},
|
|
75
|
+
commit: (messagePath, trailer) => {
|
|
76
|
+
const args = ["commit", "-F", messagePath, ...(trailer === undefined ? [] : ["--trailer", trailer])];
|
|
77
|
+
return spawn(gitPath, args, { cwd: repoRoot, env: gitFreeEnv(env), stdio: "inherit" }).status;
|
|
78
|
+
},
|
|
45
79
|
};
|
|
46
80
|
}
|
|
47
81
|
//# sourceMappingURL=git.js.map
|
package/dist/adapters/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../src/adapters/git.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,WAAW,CAAC;AAI7B;;;;GAIG;AACH,MAAM,cAAc,GAAG,CAAC,mBAAmB,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,CAAU,CAAC;AAE5F;;;;GAIG;AACH,MAAM,aAAa,GAAsB,CAAC,SAAS,EAAE,gBAAgB,EAAE,eAAe,EAAE,YAAY,EAAE,gBAAgB,CAAC,CAAC;AAExH,4DAA4D;AAC5D,MAAM,UAAU,cAAc,CAAC,MAAsC;IACjE,KAAK,MAAM,GAAG,IAAI,cAAc,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACxC,IAAI,MAAM,CAAC,SAAS,CAAC;YAAE,OAAO,SAAS,CAAC;IAC5C,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;AACvE,CAAC;AAED,sDAAsD;AACtD,MAAM,UAAU,UAAU,CAAC,GAAiD;IACxE,MAAM,OAAO,GAAuC,EAAE,CAAC;IACvD,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QAC7C,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;IAC3D,CAAC;IACD,OAAO,OAAO,CAAC;AACnB,CAAC;AAWD,uEAAuE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AAK,CAAC,CAAC,CAAC;QACjC,CAAC;QACD,MAAM,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,EAAE;YAC7B,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;YAErG,OAAO,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClG,CAAC;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProcessPort, SpawnPort } from "../ports.js";
|
|
2
|
+
/**
|
|
3
|
+
* The real process table. Ancestry is read through `ps`, the only portable
|
|
4
|
+
* parent lookup on macOS and Linux; the walk stops at pid 1.
|
|
5
|
+
*/
|
|
6
|
+
export declare function createProcessPort(spawn: SpawnPort): ProcessPort;
|
|
7
|
+
//# sourceMappingURL=process.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../src/adapters/process.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,GAAG,WAAW,CAoC/D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The real process table. Ancestry is read through `ps`, the only portable
|
|
3
|
+
* parent lookup on macOS and Linux; the walk stops at pid 1.
|
|
4
|
+
*/
|
|
5
|
+
export function createProcessPort(spawn) {
|
|
6
|
+
const parentOf = (pid) => {
|
|
7
|
+
const result = spawn("ps", ["-o", "ppid=", "-p", String(pid)]);
|
|
8
|
+
if (result.status !== 0)
|
|
9
|
+
return undefined;
|
|
10
|
+
const parent = Number(result.stdout.trim());
|
|
11
|
+
return Number.isInteger(parent) && parent > 0 ? parent : undefined;
|
|
12
|
+
};
|
|
13
|
+
return {
|
|
14
|
+
pid: process.pid,
|
|
15
|
+
isAlive: (pid) => {
|
|
16
|
+
if (!Number.isInteger(pid) || pid <= 0)
|
|
17
|
+
return false;
|
|
18
|
+
try {
|
|
19
|
+
process.kill(pid, 0);
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
// EPERM: the process exists but belongs to someone else.
|
|
24
|
+
return error.code === "EPERM";
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
ancestors: () => {
|
|
28
|
+
const chain = [];
|
|
29
|
+
let current = process.pid;
|
|
30
|
+
for (;;) {
|
|
31
|
+
const parent = parentOf(current);
|
|
32
|
+
if (parent === undefined || parent <= 1 || chain.includes(parent))
|
|
33
|
+
break;
|
|
34
|
+
chain.push(parent);
|
|
35
|
+
current = parent;
|
|
36
|
+
}
|
|
37
|
+
return chain;
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../src/adapters/process.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAgB;IAC9C,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAsB,EAAE;QACjD,MAAM,MAAM,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC/D,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,SAAS,CAAC;QAE1C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC;QAE5C,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IACvE,CAAC,CAAC;IAEF,OAAO;QACH,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE;YACb,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC;gBAAE,OAAO,KAAK,CAAC;YACrD,IAAI,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;gBACrB,OAAO,IAAI,CAAC;YAChB,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,yDAAyD;gBACzD,OAAQ,KAA+B,CAAC,IAAI,KAAK,OAAO,CAAC;YAC7D,CAAC;QACL,CAAC;QACD,SAAS,EAAE,GAAG,EAAE;YACZ,MAAM,KAAK,GAAa,EAAE,CAAC;YAC3B,IAAI,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC;YAE1B,SAAS,CAAC;gBACN,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;gBACjC,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,IAAI,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC;oBAAE,MAAM;gBACzE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBACnB,OAAO,GAAG,MAAM,CAAC;YACrB,CAAC;YAED,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ,CAAC;AACN,CAAC"}
|
package/dist/bin.js
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { existsSync, readFileSync } from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
+
import { systemClock } from "./adapters/clock.js";
|
|
5
|
+
import { createFileSystemPort } from "./adapters/fs.js";
|
|
4
6
|
import { createGitPort, resolveGitPath } from "./adapters/git.js";
|
|
7
|
+
import { createProcessPort } from "./adapters/process.js";
|
|
5
8
|
import { createSpawnPort } from "./adapters/spawn.js";
|
|
6
9
|
import { main } from "./cli.js";
|
|
7
10
|
/**
|
|
@@ -15,6 +18,9 @@ process.exitCode = main(process.argv.slice(2), {
|
|
|
15
18
|
cwd,
|
|
16
19
|
spawn,
|
|
17
20
|
git: createGitPort({ repoRoot: cwd, spawn, env: process.env, gitPath: resolveGitPath(existsSync) }),
|
|
21
|
+
fs: createFileSystemPort(),
|
|
22
|
+
process: createProcessPort(spawn),
|
|
23
|
+
clock: systemClock,
|
|
18
24
|
readConfig: (file) => JSON.parse(readFileSync(path.resolve(cwd, file), "utf8")),
|
|
19
25
|
write: (line) => process.stdout.write(`${line}\n`),
|
|
20
26
|
writeError: (line) => process.stderr.write(`${line}\n`),
|
package/dist/bin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAEhC;;;;GAIG;AACH,MAAM,GAAG,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;AAC1B,MAAM,KAAK,GAAG,eAAe,EAAE,CAAC;AAEhC,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE;IAC3C,GAAG;IACH,KAAK;IACL,GAAG,EAAE,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;IAC3C,GAAG;IACH,KAAK;IACL,GAAG,EAAE,aAAa,CAAC,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,cAAc,CAAC,UAAU,CAAC,EAAE,CAAC;IACnG,EAAE,EAAE,oBAAoB,EAAE;IAC1B,OAAO,EAAE,iBAAiB,CAAC,KAAK,CAAC;IACjC,KAAK,EAAE,WAAW;IAClB,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,CAAY;IAC1F,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;IAClD,UAAU,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,IAAI,CAAC;CAC1D,CAAC,CAAC"}
|
package/dist/cli.d.ts
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import type { DiffMode, GitPort, SpawnPort } from "./ports.js";
|
|
1
|
+
import type { ClockPort, DiffMode, FileSystemPort, GitPort, ProcessPort, SpawnPort } from "./ports.js";
|
|
2
2
|
export declare const USAGE: string;
|
|
3
3
|
/** Everything `main` touches, so a test can bind fakes and a consumer the machine. */
|
|
4
4
|
export interface CliDeps {
|
|
5
5
|
readonly cwd: string;
|
|
6
6
|
readonly spawn: SpawnPort;
|
|
7
7
|
readonly git: GitPort;
|
|
8
|
+
readonly fs: FileSystemPort;
|
|
9
|
+
readonly process: ProcessPort;
|
|
10
|
+
readonly clock: ClockPort;
|
|
8
11
|
/** Read a config file relative to [cwd]; throws when it cannot. */
|
|
9
12
|
readonly readConfig: (path: string) => unknown;
|
|
10
13
|
readonly write: (line: string) => void;
|
|
@@ -18,12 +21,57 @@ export interface SuiteSelectOptions {
|
|
|
18
21
|
readonly configPath: string;
|
|
19
22
|
readonly paths: readonly string[];
|
|
20
23
|
}
|
|
24
|
+
/** What one command line asks for. Anything unrecognised is a usage error. */
|
|
21
25
|
export type ParsedArgs = {
|
|
22
26
|
readonly kind: "usage";
|
|
23
27
|
} | ({
|
|
24
|
-
readonly kind: "
|
|
25
|
-
} & SuiteSelectOptions)
|
|
26
|
-
|
|
28
|
+
readonly kind: "suite-select";
|
|
29
|
+
} & SuiteSelectOptions) | {
|
|
30
|
+
readonly kind: "suite-fast";
|
|
31
|
+
readonly dryRun: boolean;
|
|
32
|
+
readonly configPath: string;
|
|
33
|
+
readonly paths: readonly string[];
|
|
34
|
+
} | {
|
|
35
|
+
readonly kind: "run";
|
|
36
|
+
readonly dryRun: boolean;
|
|
37
|
+
readonly fast: boolean;
|
|
38
|
+
readonly configPath: string;
|
|
39
|
+
readonly paths: readonly string[];
|
|
40
|
+
} | {
|
|
41
|
+
readonly kind: "tier";
|
|
42
|
+
readonly tier: "preflight" | "commit" | "push";
|
|
43
|
+
readonly dryRun: boolean;
|
|
44
|
+
readonly configPath: string;
|
|
45
|
+
} | {
|
|
46
|
+
readonly kind: "tier-message";
|
|
47
|
+
readonly messagePath: string;
|
|
48
|
+
readonly configPath: string;
|
|
49
|
+
} | {
|
|
50
|
+
readonly kind: "lock-acquire";
|
|
51
|
+
readonly label: string;
|
|
52
|
+
} | {
|
|
53
|
+
readonly kind: "lock-release";
|
|
54
|
+
readonly pid: number;
|
|
55
|
+
} | {
|
|
56
|
+
readonly kind: "receipt";
|
|
57
|
+
readonly action: "check" | "write";
|
|
58
|
+
} | {
|
|
59
|
+
readonly kind: "coverage-changed-lines";
|
|
60
|
+
readonly range?: string;
|
|
61
|
+
} | {
|
|
62
|
+
readonly kind: "ratchet";
|
|
63
|
+
} | {
|
|
64
|
+
readonly kind: "commit";
|
|
65
|
+
readonly messagePath: string;
|
|
66
|
+
readonly task?: string;
|
|
67
|
+
readonly dryRun: boolean;
|
|
68
|
+
readonly configPath: string;
|
|
69
|
+
} | {
|
|
70
|
+
readonly kind: "version-bump";
|
|
71
|
+
} | {
|
|
72
|
+
readonly kind: "new-source";
|
|
73
|
+
};
|
|
74
|
+
/** Parse a command line; everything outside the documented commands is a usage error. */
|
|
27
75
|
export declare function parseArgs(argv: readonly string[]): ParsedArgs;
|
|
28
76
|
/** Run the gate CLI; returns the process exit code. */
|
|
29
77
|
export declare function main(argv: readonly string[], deps: CliDeps): number;
|
package/dist/cli.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,SAAS,EAAE,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvG,eAAO,MAAM,KAAK,QAiBN,CAAC;AAEb,sFAAsF;AACtF,MAAM,WAAW,OAAO;IACpB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,EAAE,cAAc,CAAC;IAC5B,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;IAC9B,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAC1B,mEAAmE;IACnE,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC;IAC/C,QAAQ,CAAC,KAAK,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CAC/C;AAED,MAAM,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