sxh-quality-checks 0.1.1 → 0.2.1

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 (90) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +182 -20
  3. package/dist/adapters/clock.d.ts +4 -0
  4. package/dist/adapters/clock.d.ts.map +1 -0
  5. package/dist/adapters/clock.js +3 -0
  6. package/dist/adapters/clock.js.map +1 -0
  7. package/dist/adapters/fs.d.ts +4 -0
  8. package/dist/adapters/fs.d.ts.map +1 -0
  9. package/dist/adapters/fs.js +52 -0
  10. package/dist/adapters/fs.js.map +1 -0
  11. package/dist/adapters/git.d.ts.map +1 -1
  12. package/dist/adapters/git.js +36 -2
  13. package/dist/adapters/git.js.map +1 -1
  14. package/dist/adapters/process.d.ts +7 -0
  15. package/dist/adapters/process.d.ts.map +1 -0
  16. package/dist/adapters/process.js +41 -0
  17. package/dist/adapters/process.js.map +1 -0
  18. package/dist/bin.js +6 -0
  19. package/dist/bin.js.map +1 -1
  20. package/dist/cli.d.ts +55 -4
  21. package/dist/cli.d.ts.map +1 -1
  22. package/dist/cli.js +556 -61
  23. package/dist/cli.js.map +1 -1
  24. package/dist/commit.d.ts +31 -0
  25. package/dist/commit.d.ts.map +1 -0
  26. package/dist/commit.js +103 -0
  27. package/dist/commit.js.map +1 -0
  28. package/dist/config.d.ts +1299 -28
  29. package/dist/config.d.ts.map +1 -1
  30. package/dist/config.js +170 -0
  31. package/dist/config.js.map +1 -1
  32. package/dist/decisions/changedLines.d.ts +111 -0
  33. package/dist/decisions/changedLines.d.ts.map +1 -0
  34. package/dist/decisions/changedLines.js +281 -0
  35. package/dist/decisions/changedLines.js.map +1 -0
  36. package/dist/decisions/fastPlan.d.ts +11 -0
  37. package/dist/decisions/fastPlan.d.ts.map +1 -0
  38. package/dist/decisions/fastPlan.js +61 -0
  39. package/dist/decisions/fastPlan.js.map +1 -0
  40. package/dist/decisions/planTier.d.ts +41 -0
  41. package/dist/decisions/planTier.d.ts.map +1 -0
  42. package/dist/decisions/planTier.js +63 -0
  43. package/dist/decisions/planTier.js.map +1 -0
  44. package/dist/index.d.ts +15 -2
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/index.js +14 -1
  47. package/dist/index.js.map +1 -1
  48. package/dist/lock.d.ts +42 -0
  49. package/dist/lock.d.ts.map +1 -0
  50. package/dist/lock.js +54 -0
  51. package/dist/lock.js.map +1 -0
  52. package/dist/newSource.d.ts +33 -0
  53. package/dist/newSource.d.ts.map +1 -0
  54. package/dist/newSource.js +79 -0
  55. package/dist/newSource.js.map +1 -0
  56. package/dist/ports.d.ts +42 -0
  57. package/dist/ports.d.ts.map +1 -1
  58. package/dist/ratchet.d.ts +53 -0
  59. package/dist/ratchet.d.ts.map +1 -0
  60. package/dist/ratchet.js +92 -0
  61. package/dist/ratchet.js.map +1 -0
  62. package/dist/receipt.d.ts +16 -0
  63. package/dist/receipt.d.ts.map +1 -0
  64. package/dist/receipt.js +14 -0
  65. package/dist/receipt.js.map +1 -0
  66. package/dist/suiteRun.d.ts +58 -0
  67. package/dist/suiteRun.d.ts.map +1 -0
  68. package/dist/suiteRun.js +94 -0
  69. package/dist/suiteRun.js.map +1 -0
  70. package/dist/testing/fs.d.ts +15 -0
  71. package/dist/testing/fs.d.ts.map +1 -0
  72. package/dist/testing/fs.js +30 -0
  73. package/dist/testing/fs.js.map +1 -0
  74. package/dist/testing/git.d.ts +10 -0
  75. package/dist/testing/git.d.ts.map +1 -1
  76. package/dist/testing/git.js +8 -0
  77. package/dist/testing/git.js.map +1 -1
  78. package/dist/testing/index.d.ts +2 -0
  79. package/dist/testing/index.d.ts.map +1 -1
  80. package/dist/testing/index.js +2 -0
  81. package/dist/testing/index.js.map +1 -1
  82. package/dist/testing/process.d.ts +15 -0
  83. package/dist/testing/process.d.ts.map +1 -0
  84. package/dist/testing/process.js +12 -0
  85. package/dist/testing/process.js.map +1 -0
  86. package/dist/version.d.ts +28 -0
  87. package/dist/version.d.ts.map +1 -0
  88. package/dist/version.js +50 -0
  89. package/dist/version.js.map +1 -0
  90. 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,75 @@ temporary repositories the tests create.
23
23
  ## Usage
24
24
 
25
25
  ```sh
26
- quality-checks suite select --cached --dry-run # print the plan for the staged tree
27
- quality-checks suite select --cached # run the selected suites, stopping at the first failure
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
44
+ quality-checks suite run root -- vitest run --coverage # run a suite, record its failures
28
45
  ```
29
46
 
30
- | Flag | Effect |
31
- | ------------------------- | ------------------------------------------------------------------ |
32
- | `--cached` / `--worktree` | judge the staged tree (a commit) or the working tree (the default) |
33
- | `--with-mutation` | run a suite's `mutateCommand` after it |
34
- | `--coverage` | run a suite's `coverageCommand` instead of its ordinary one |
35
- | `--dry-run` | print each command instead of running it |
36
- | `--config <path>` | config file, default `gate.config.json` at the working directory |
37
- | `path…` | judge these paths instead of asking git for the diff |
47
+ | Command | Judges | Config it uses |
48
+ | -------------- | ----------------------------------------------------- | ---------------------------------- |
49
+ | `run` | the working tree, or the paths given | `tiers.run` |
50
+ | `run --fast` | named test files only | `tiers.preflight` + `fast.runners` |
51
+ | `tier commit` | the staged tree (a commit in progress) | `tiers.commit` |
52
+ | `tier push` | the checkout | `tiers.push` |
53
+ | `tier message` | the commit message git handed the hook (`$1`) | `tiers.message` |
54
+ | `suite select` | the staged or working diff | `suites`, `fallback` |
55
+ | `suite fast` | named test files only | `fast.runners` |
56
+ | `suite run` | the suite command, with failures recorded in `.gate/` | — |
38
57
 
39
- A docs- or PCP-only diff selects nothing. A code path no suite recognises runs
40
- the configured `fallback` — an unrecognised path is not evidence that nothing
41
- needs running.
58
+ `suite run` appends vitest's JSON reporter to the command and, on a non-zero
59
+ exit, writes `.gate/<suite>-failures.json` with each failing test's message and
60
+ stack. The console output is unchanged and the exit status passes through, so a
61
+ failure keeps its cause even when the log is piped, and a run that crashed
62
+ before the reporter wrote names the console as the only record.
63
+ | `lock` | one gate run at a time (0 taken, 3 refused, 4 nested) | — |
64
+ | `receipt` | the staged tree's commit-tier receipt | — |
65
+ | `coverage changed-lines` | statements that start on a line the diff adds or changes | `changedLines` |
66
+ | `ratchet` | the lint warning count against its baseline | `ratchet` |
67
+ | `commit` | close → stage → bump → tier → receipt → commit | `commit`, `version` |
68
+ | `version bump` | the version file and its generated constant | `version` |
69
+ | `new-source` | staged new source files and their tests | `newSource` |
70
+
71
+ Every tier ends with the same verdict line and the real exit code —
72
+ `gate: PASSED (0)` or `gate: FAILED (<code>)` — so a piped or truncated log
73
+ cannot turn a failure into a success.
74
+
75
+ The lock and the receipt live beside the git directory (`gate.lock`,
76
+ `gate-receipt`). The lock is keyed by pid: a lock whose holder is gone is
77
+ reclaimed automatically, and a run the holder itself started is treated as part
78
+ of the same gate. The receipt is keyed by `git write-tree`: any further staged
79
+ edit changes the hash, so a tree the tier has never seen cannot be skipped.
80
+
81
+ Common flags: `--dry-run` prints each step instead of running it; `--config`
82
+ selects another config file; `suite select` also takes `--cached`,
83
+ `--with-mutation` and `--coverage`.
84
+
85
+ `tier commit` takes the declared docs fast path when every staged path is
86
+ documentation or PCP state; `commit.docsOnly` is required in the config, so a
87
+ docs-only commit cannot silently run nothing.
42
88
 
43
89
  ## Config
44
90
 
45
91
  ```json
46
92
  {
47
93
  "docs": { "files": ["VERSION"], "dirs": ["docs/", ".opencode/pcp/"], "extensions": [".md"] },
48
- "fallback": ["dart", "root"],
94
+ "fallback": ["root"],
49
95
  "suites": [
50
96
  {
51
97
  "name": "dart",
@@ -59,20 +105,136 @@ needs running.
59
105
  "mutateCommand": ["bash", "scripts/mutate-changed.sh"],
60
106
  "match": [{ "prefix": "packages/functions/" }]
61
107
  }
62
- ]
108
+ ],
109
+ "tiers": {
110
+ "run": [{ "lock": "hold" }, { "tier": "preflight" }, { "suites": { "mutation": true, "coverage": true } }],
111
+ "preflight": [{ "run": ["npm", "run", "format"] }, { "run": ["npm", "run", "lint"] }],
112
+ "commit": {
113
+ "steps": [{ "receipt": "check" }, { "run": ["bash", "scripts/preflight.sh"] }, { "suites": {} }],
114
+ "docsOnly": [{ "receipt": "check" }, { "tier": "preflight" }]
115
+ },
116
+ "push": [{ "lock": "hold" }, { "run": ["npm", "run", "test:all"] }],
117
+ "message": { "commands": [["bash", "scripts/check-pcp-task.sh"]] }
118
+ },
119
+ "fast": {
120
+ "runners": [
121
+ { "command": ["npx", "vitest", "run"], "suffixes": [".test.ts", ".test.tsx"] },
122
+ {
123
+ "command": ["npx", "vitest", "run"],
124
+ "prefix": "packages/core/",
125
+ "cwd": "packages/core",
126
+ "suffixes": [".test.ts"]
127
+ }
128
+ ]
129
+ },
130
+ "changedLines": {
131
+ "sources": [
132
+ {
133
+ "pattern": "^packages/core/src/.*\\.ts$",
134
+ "report": "packages/core/coverage/coverage-final.json",
135
+ "format": "istanbul",
136
+ "suite": "npm test --workspace @rpg/core"
137
+ },
138
+ {
139
+ "pattern": "^packages/combat_app/lib/.*\\.dart$",
140
+ "report": "packages/combat_app/coverage/lcov.info",
141
+ "format": "lcov",
142
+ "prefix": "packages/combat_app/",
143
+ "suite": "bash scripts/cover.sh"
144
+ }
145
+ ],
146
+ "excludeFiles": ["index.ts", "main.dart"],
147
+ "excludePaths": ["scripts/spikes/"]
148
+ },
149
+ "ratchet": { "command": ["npx", "eslint", ".", "--format", "json"], "baseline": ".eslint-warning-count" },
150
+ "version": {
151
+ "file": "VERSION",
152
+ "generated": {
153
+ "path": "packages/combat_app/lib/app_version.dart",
154
+ "template": "// Generated from VERSION.\nconst appVersion = '{{version}}';\n"
155
+ }
156
+ },
157
+ "newSource": {
158
+ "sources": [
159
+ { "pattern": "^packages/[^/]+/src/.+\\.ts$", "test": "beside", "suffix": ".test.ts" },
160
+ { "pattern": "^packages/[^/]+/lib/.+\\.dart$", "test": "package-test-dir", "suffix": "_test.dart" }
161
+ ],
162
+ "excludeFiles": ["index.ts", "types.ts"]
163
+ },
164
+ "commit": {
165
+ "taskClose": {
166
+ "command": ["npx", "tsx", "scripts/close-pcp-task.ts"],
167
+ "trailer": "PCP-Task",
168
+ "stateFiles": [".opencode/pcp/stack.json", ".opencode/pcp/events.jsonl", ".opencode/pcp/WORKLOG.md"]
169
+ },
170
+ "requireHooksPath": "hooks"
171
+ }
63
172
  }
64
173
  ```
65
174
 
66
175
  `suites` is in run order. A `match` entry may name a `prefix` (with its trailing
67
176
  slash), a `suffix`, or one exact `file`; every part present must match, and an
68
- entry with none is rejected. The config is validated on every read and every
69
- problem is named at once.
177
+ entry with none is rejected.
178
+
179
+ A tier step is exactly one of:
180
+
181
+ - `{ "run": ["cmd", "arg"] }` — a command;
182
+ - `{ "suites": { "mutation": bool, "coverage": bool } }` — the suites the diff
183
+ selects (both options default to false);
184
+ - `{ "tier": "preflight" }` — another tier's steps, inlined. A tier that
185
+ references itself, directly or through another, is rejected when planned;
186
+ - `{ "lock": "hold" }` — take the gate lock for the rest of the tier, released
187
+ when the tier ends. A dry run prints it without taking it;
188
+ - `{ "receipt": "check" }` — stop the tier successfully when the staged tree is
189
+ the one the commit tier already passed; `{ "receipt": "write" }` records it.
190
+
191
+ `fast.runners` plan the inner loop: each named test file belongs to the runner
192
+ with the longest matching `prefix`, must end in one of its `suffixes`, and runs
193
+ in its `cwd` (with the prefix stripped). A path no runner owns is an error, not
194
+ a skip.
195
+
196
+ `changedLines.sources` say which source each report judges: the pattern picks
197
+ the files, `report` names the report, `suite` names the command that rewrites
198
+ it. A changed statement (one that _starts_ on a line the diff adds or changes)
199
+ with zero hits fails the gate. A report older than the newest changed source it
200
+ would judge also fails — judging with it could pass an uncovered line as
201
+ covered. Only the additional exclusions the app needs belong in the config;
202
+ tests and generated declarations are excluded by the engine.
203
+
204
+ `ratchet` runs the app's lint command expecting JSON (`eslint . --format json`)
205
+ and holds the total warning count to the baseline file. Errors, or a count above
206
+ the baseline, fail; a lower count rewrites the baseline; there is no automatic
207
+ raise. A baseline that is not a count is a failure, not a reset.
70
208
 
71
- ## Hook shim
209
+ `commit` is the whole commit in one command: close the task through the app's
210
+ configured adapter, stage the work, bump the version, run the commit tier,
211
+ record the receipt, then commit with the task trailer. On any failure the task
212
+ state files are restored, so the task stays open for the next attempt. With
213
+ `requireHooksPath` set, a checkout whose hooks are disabled is refused — the
214
+ commit would otherwise land unjudged.
72
215
 
73
- An app's hook is three lines; the decisions live in the package:
216
+ `version` and `newSource` mirror the same discipline: a version that is not a
217
+ number fails rather than becoming `NaN`; a new source file whose test is not in
218
+ the same commit fails, naming the test it expected.
219
+
220
+ The config is validated on every read and every problem is named at once; each
221
+ object is strict, so a misspelt key is an error rather than a silent no-op.
222
+
223
+ ## Hook shims
224
+
225
+ An app's hooks are three lines; the decisions live in the package:
226
+
227
+ ```sh
228
+ #!/bin/sh
229
+ exec npx --no-install quality-checks tier commit
230
+ ```
231
+
232
+ ```sh
233
+ #!/bin/sh
234
+ exec npx --no-install quality-checks tier push
235
+ ```
74
236
 
75
237
  ```sh
76
238
  #!/bin/sh
77
- exec npx --no-install quality-checks suite select --cached
239
+ exec npx --no-install quality-checks tier message "$1"
78
240
  ```
@@ -0,0 +1,4 @@
1
+ import type { ClockPort } from "../ports.js";
2
+ /** The real clock, as the ISO-8601 text the lock's `started` field records. */
3
+ export declare const systemClock: ClockPort;
4
+ //# sourceMappingURL=clock.d.ts.map
@@ -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,3 @@
1
+ /** The real clock, as the ISO-8601 text the lock's `started` field records. */
2
+ export const systemClock = () => new Date().toISOString();
3
+ //# sourceMappingURL=clock.js.map
@@ -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,4 @@
1
+ import type { FileSystemPort } from "../ports.js";
2
+ /** The real filesystem: absent files read as undefined, and exclusive create is atomic. */
3
+ export declare function createFileSystemPort(): FileSystemPort;
4
+ //# sourceMappingURL=fs.d.ts.map
@@ -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,CAqCrD"}
@@ -0,0 +1,52 @@
1
+ import { mkdirSync, 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
+ mkdir: (path) => {
24
+ mkdirSync(path, { recursive: true });
25
+ },
26
+ createExclusive: (path, content) => {
27
+ try {
28
+ writeFileSync(path, content, { flag: "wx" });
29
+ return true;
30
+ }
31
+ catch (error) {
32
+ if (codeOf(error) === ALREADY_EXISTS)
33
+ return false;
34
+ throw error;
35
+ }
36
+ },
37
+ remove: (path) => {
38
+ rmSync(path, { force: true });
39
+ },
40
+ mtime: (path) => {
41
+ try {
42
+ return statSync(path).mtimeMs;
43
+ }
44
+ catch (error) {
45
+ if (codeOf(error) === MISSING)
46
+ return null;
47
+ throw error;
48
+ }
49
+ },
50
+ };
51
+ }
52
+ //# sourceMappingURL=fs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.js","sourceRoot":"","sources":["../../src/adapters/fs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAGnF,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,EAAE,CAAC,IAAI,EAAE,EAAE;YACX,IAAI,CAAC;gBACD,OAAO,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;YACtC,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACb,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,OAAO;oBAAE,OAAO,SAAS,CAAC;gBAChD,MAAM,KAAK,CAAC;YAChB,CAAC;QACL,CAAC;QACD,KAAK,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YACrB,aAAa,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;QACjC,CAAC;QACD,KAAK,EAAE,CAAC,IAAI,EAAE,EAAE;YACZ,SAAS,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,CAAC;QACD,eAAe,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE;YAC/B,IAAI,CAAC;gBACD,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;gBAC7C,OAAO,IAAI,C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AAE,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,CAexF"}
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"}
@@ -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 lines = (args) => {
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.stdout.split("\n").filter((line) => line !== "");
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
@@ -1 +1 @@
1
-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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,i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BACzE,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,E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C;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,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,60 @@ 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: "ok";
25
- } & SuiteSelectOptions);
26
- /** Parse `suite select` arguments; everything else is a usage error. */
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: "suite-run";
36
+ readonly argv: readonly string[];
37
+ } | {
38
+ readonly kind: "run";
39
+ readonly dryRun: boolean;
40
+ readonly fast: boolean;
41
+ readonly configPath: string;
42
+ readonly paths: readonly string[];
43
+ } | {
44
+ readonly kind: "tier";
45
+ readonly tier: "preflight" | "commit" | "push";
46
+ readonly dryRun: boolean;
47
+ readonly configPath: string;
48
+ } | {
49
+ readonly kind: "tier-message";
50
+ readonly messagePath: string;
51
+ readonly configPath: string;
52
+ } | {
53
+ readonly kind: "lock-acquire";
54
+ readonly label: string;
55
+ } | {
56
+ readonly kind: "lock-release";
57
+ readonly pid: number;
58
+ } | {
59
+ readonly kind: "receipt";
60
+ readonly action: "check" | "write";
61
+ } | {
62
+ readonly kind: "coverage-changed-lines";
63
+ readonly range?: string;
64
+ } | {
65
+ readonly kind: "ratchet";
66
+ } | {
67
+ readonly kind: "commit";
68
+ readonly messagePath: string;
69
+ readonly task?: string;
70
+ readonly dryRun: boolean;
71
+ readonly configPath: string;
72
+ } | {
73
+ readonly kind: "version-bump";
74
+ } | {
75
+ readonly kind: "new-source";
76
+ };
77
+ /** Parse a command line; everything outside the documented commands is a usage error. */
27
78
  export declare function parseArgs(argv: readonly string[]): ParsedArgs;
28
79
  /** Run the gate CLI; returns the process exit code. */
29
80
  export declare function main(argv: readonly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