@tayomi/deterministic-gates 0.6.1 → 0.7.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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/catalog/angular.json +28 -4
- package/catalog/index.html +33 -7
- package/catalog/typescript.json +3 -2
- package/dist/src/core/config.js +10 -4
- package/dist/src/core/watch.js +214 -78
- package/dist/src/helpers/template-errors.js +85 -0
- package/dist/src/helpers/tsc.js +1 -1
- package/dist/src/helpers/type-errors.js +22 -14
- package/package.json +1 -1
- package/src/core/config.ts +14 -4
- package/src/core/watch.ts +224 -74
- package/src/helpers/template-errors.ts +101 -0
- package/src/helpers/tsc.ts +1 -1
- package/src/helpers/type-errors.ts +35 -15
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://json.schemastore.org/claude-code-plugin-manifest.json",
|
|
3
3
|
"name": "deterministic-gates",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "Deterministic backpressure for coding agents: gates that run on what each turn changed and send the agent back until they pass.",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Pierre Moati",
|
package/catalog/angular.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Gates for an Angular project tested with Vitest through the Angular builder, ng test. Each tool comes from the repo's node_modules, so its version is the one the lockfile pins.",
|
|
4
4
|
"gates": [
|
|
5
5
|
{
|
|
6
|
-
"description": "Runs the unit tests in a watch kept warm between turns, since ng test builds the whole application before a single test runs. At the stop, it waits for the watch to finish with the turn's changes, then fails on a build that does not compile, and on every red spec, the ones the change did not rerun included. The whole check runs ng test once, without a watch.",
|
|
6
|
+
"description": "Runs the unit tests in a watch kept warm between turns, since ng test builds the whole application before a single test runs. At the stop, it waits for the watch to finish with the turn's changes, then fails on a build that does not compile, and on every red spec, the ones the change did not rerun included. The whole check runs ng test once, without a watch. The watch is asked for a cycle through tsconfig.spec.json, and starts again when a spec is created or deleted, since ng test lists its specs once.",
|
|
7
7
|
"requires": [
|
|
8
8
|
{
|
|
9
9
|
"tool": "@angular/cli",
|
|
@@ -27,12 +27,14 @@
|
|
|
27
27
|
"run": ["{engine}/src/helpers/angular-watch.ts"],
|
|
28
28
|
"cycleStart": "Changes detected\\. Rebuilding",
|
|
29
29
|
"cycleEnd": "Test run finished with success|bundle generation failed",
|
|
30
|
-
"failed": "^FAIL |bundle generation failed"
|
|
30
|
+
"failed": "^FAIL |bundle generation failed",
|
|
31
|
+
"sync": "tsconfig.spec.json",
|
|
32
|
+
"frozen": "\\.spec\\.ts$"
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
},
|
|
34
36
|
{
|
|
35
|
-
"description": "Builds the application in a watch kept warm between turns, which type-checks every template, the ones of a component no spec reaches included: tsc alone never reads a template. At the stop, it fails on a build that does not compile, with the file and line of each error. Built without optimization into node_modules/.cache, so the dist of the project stays as it is. The whole check builds once, without a watch.",
|
|
37
|
+
"description": "Builds the application in a watch kept warm between turns, which type-checks every template, the ones of a component no spec reaches included: tsc alone never reads a template. At the stop, it fails on a build that does not compile, with the file and line of each error. Built without optimization into node_modules/.cache, so the dist of the project stays as it is. The whole check builds once, without a watch. The watch is asked for a cycle through tsconfig.app.json.",
|
|
36
38
|
"requires": [
|
|
37
39
|
{
|
|
38
40
|
"tool": "@angular/cli",
|
|
@@ -58,7 +60,8 @@
|
|
|
58
60
|
],
|
|
59
61
|
"cycleStart": "Changes detected\\. Rebuilding",
|
|
60
62
|
"cycleEnd": "Application bundle generation (complete|failed)",
|
|
61
|
-
"failed": "Application bundle generation failed"
|
|
63
|
+
"failed": "Application bundle generation failed",
|
|
64
|
+
"sync": "tsconfig.app.json"
|
|
62
65
|
}
|
|
63
66
|
}
|
|
64
67
|
},
|
|
@@ -80,6 +83,27 @@
|
|
|
80
83
|
"files": "\\.html$",
|
|
81
84
|
"run": ["eslint", "--max-warnings", "0", "--no-warn-ignored", "{files}"]
|
|
82
85
|
}
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"description": "Fails on the strict template errors the turn added, never on the ones already there, for a project that turned strictTemplates off: it compiles the templates with strictTemplates and strictNullChecks forced on top of the project's options, through the API of the Angular compiler, so a binding that may be null is reported even when the TypeScript has strict errors of its own. The build gate checks the templates with the project's own options. An error is not new when moved, or reported with the same message in another file the turn did not change, or on a changed line as long as its file has no more errors of its code than at the turn start. It checks tsconfig.app.json: give its -p the tsconfig of the application.",
|
|
89
|
+
"requires": [
|
|
90
|
+
{
|
|
91
|
+
"tool": "@angular/compiler-cli",
|
|
92
|
+
"install": "npm install --save-dev @angular/compiler-cli"
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"tool": "typescript",
|
|
96
|
+
"install": "npm install --save-dev typescript"
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"gate": {
|
|
100
|
+
"name": "no-new-strict-template-errors",
|
|
101
|
+
"severity": "error",
|
|
102
|
+
"files": "(\\.(ts|html)|(^|/)tsconfig[^/]*\\.json)$",
|
|
103
|
+
"run": ["{engine}/src/helpers/template-errors.ts", "-p", "tsconfig.app.json", "--strictNullChecks"],
|
|
104
|
+
"compare": "turn-start",
|
|
105
|
+
"lineKey": "^((?<file>.+?): error (?:TS|NG)\\d+) at [^\\t]*"
|
|
106
|
+
}
|
|
83
107
|
}
|
|
84
108
|
]
|
|
85
109
|
}
|
package/catalog/index.html
CHANGED
|
@@ -40,14 +40,14 @@ summary { cursor: pointer; color: var(--muted); }
|
|
|
40
40
|
<h1>Gate catalog</h1>
|
|
41
41
|
<p>The gates worth copying into a repo. Nothing here runs by itself: the engine reads only the repo's <code>.gates.json</code>. Copy the definition of a gate there, install what it requires, and adapt its <code>files</code> to the layout of the repo.</p>
|
|
42
42
|
<p>Generated from <code>catalog/*.json</code> by <code>pnpm catalog</code>: edit those files, never this page.</p>
|
|
43
|
-
<nav><a href="#angular">Angular (
|
|
43
|
+
<nav><a href="#angular">Angular (4)</a><a href="#go">Go (6)</a><a href="#python">Python (3)</a><a href="#typescript">TypeScript (9)</a></nav>
|
|
44
44
|
</header>
|
|
45
45
|
<section id="angular">
|
|
46
46
|
<h2>Angular</h2>
|
|
47
47
|
<p>Gates for an Angular project tested with Vitest through the Angular builder, ng test. Each tool comes from the repo's node_modules, so its version is the one the lockfile pins.</p>
|
|
48
48
|
<article id="angular/tests">
|
|
49
49
|
<h3><code>angular/tests</code></h3>
|
|
50
|
-
<p>Runs the unit tests in a watch kept warm between turns, since ng test builds the whole application before a single test runs. At the stop, it waits for the watch to finish with the turn's changes, then fails on a build that does not compile, and on every red spec, the ones the change did not rerun included. The whole check runs ng test once, without a watch.</p>
|
|
50
|
+
<p>Runs the unit tests in a watch kept warm between turns, since ng test builds the whole application before a single test runs. At the stop, it waits for the watch to finish with the turn's changes, then fails on a build that does not compile, and on every red spec, the ones the change did not rerun included. The whole check runs ng test once, without a watch. The watch is asked for a cycle through tsconfig.spec.json, and starts again when a spec is created or deleted, since ng test lists its specs once.</p>
|
|
51
51
|
<dl>
|
|
52
52
|
<dt>Runs</dt><dd><code>@angular/cli test --watch=false</code></dd>
|
|
53
53
|
<dt>When the turn changes</dt><dd><code>\.(ts|html|css)$</code></dd>
|
|
@@ -68,13 +68,15 @@ summary { cursor: pointer; color: var(--muted); }
|
|
|
68
68
|
],
|
|
69
69
|
"cycleStart": "Changes detected\\. Rebuilding",
|
|
70
70
|
"cycleEnd": "Test run finished with success|bundle generation failed",
|
|
71
|
-
"failed": "^FAIL |bundle generation failed"
|
|
71
|
+
"failed": "^FAIL |bundle generation failed",
|
|
72
|
+
"sync": "tsconfig.spec.json",
|
|
73
|
+
"frozen": "\\.spec\\.ts$"
|
|
72
74
|
}
|
|
73
75
|
}</code></pre></details>
|
|
74
76
|
</article>
|
|
75
77
|
<article id="angular/build">
|
|
76
78
|
<h3><code>angular/build</code></h3>
|
|
77
|
-
<p>Builds the application in a watch kept warm between turns, which type-checks every template, the ones of a component no spec reaches included: tsc alone never reads a template. At the stop, it fails on a build that does not compile, with the file and line of each error. Built without optimization into node_modules/.cache, so the dist of the project stays as it is. The whole check builds once, without a watch.</p>
|
|
79
|
+
<p>Builds the application in a watch kept warm between turns, which type-checks every template, the ones of a component no spec reaches included: tsc alone never reads a template. At the stop, it fails on a build that does not compile, with the file and line of each error. Built without optimization into node_modules/.cache, so the dist of the project stays as it is. The whole check builds once, without a watch. The watch is asked for a cycle through tsconfig.app.json.</p>
|
|
78
80
|
<dl>
|
|
79
81
|
<dt>Runs</dt><dd><code>@angular/cli build --optimization=false --output-path=node_modules/.cache/gates/build</code></dd>
|
|
80
82
|
<dt>When the turn changes</dt><dd><code>\.(ts|html|css|scss|sass|less)$</code></dd>
|
|
@@ -100,7 +102,8 @@ summary { cursor: pointer; color: var(--muted); }
|
|
|
100
102
|
],
|
|
101
103
|
"cycleStart": "Changes detected\\. Rebuilding",
|
|
102
104
|
"cycleEnd": "Application bundle generation (complete|failed)",
|
|
103
|
-
"failed": "Application bundle generation failed"
|
|
105
|
+
"failed": "Application bundle generation failed",
|
|
106
|
+
"sync": "tsconfig.app.json"
|
|
104
107
|
}
|
|
105
108
|
}</code></pre></details>
|
|
106
109
|
</article>
|
|
@@ -125,6 +128,28 @@ summary { cursor: pointer; color: var(--muted); }
|
|
|
125
128
|
]
|
|
126
129
|
}</code></pre></details>
|
|
127
130
|
</article>
|
|
131
|
+
<article id="angular/no-new-strict-template-errors">
|
|
132
|
+
<h3><code>angular/no-new-strict-template-errors</code></h3>
|
|
133
|
+
<p>Fails on the strict template errors the turn added, never on the ones already there, for a project that turned strictTemplates off: it compiles the templates with strictTemplates and strictNullChecks forced on top of the project's options, through the API of the Angular compiler, so a binding that may be null is reported even when the TypeScript has strict errors of its own. The build gate checks the templates with the project's own options. An error is not new when moved, or reported with the same message in another file the turn did not change, or on a changed line as long as its file has no more errors of its code than at the turn start. It checks tsconfig.app.json: give its -p the tsconfig of the application.</p>
|
|
134
|
+
<dl>
|
|
135
|
+
<dt>Runs</dt><dd><code>{engine}/src/helpers/template-errors.ts -p tsconfig.app.json --strictNullChecks</code></dd>
|
|
136
|
+
<dt>When the turn changes</dt><dd><code>(\.(ts|html)|(^|/)tsconfig[^/]*\.json)$</code></dd>
|
|
137
|
+
<dt>Fails on</dt><dd>only the output lines the turn added</dd><dt>Requires</dt><dd><ul><li><code>@angular/compiler-cli</code>: npm install --save-dev @angular/compiler-cli</li><li><code>typescript</code>: npm install --save-dev typescript</li></ul></dd>
|
|
138
|
+
</dl>
|
|
139
|
+
<details><summary>Definition to copy into .gates.json</summary><pre><code>{
|
|
140
|
+
"name": "no-new-strict-template-errors",
|
|
141
|
+
"severity": "error",
|
|
142
|
+
"files": "(\\.(ts|html)|(^|/)tsconfig[^/]*\\.json)$",
|
|
143
|
+
"run": [
|
|
144
|
+
"{engine}/src/helpers/template-errors.ts",
|
|
145
|
+
"-p",
|
|
146
|
+
"tsconfig.app.json",
|
|
147
|
+
"--strictNullChecks"
|
|
148
|
+
],
|
|
149
|
+
"compare": "turn-start",
|
|
150
|
+
"lineKey": "^((?<file>.+?): error (?:TS|NG)\\d+) at [^\\t]*"
|
|
151
|
+
}</code></pre></details>
|
|
152
|
+
</article>
|
|
128
153
|
</section>
|
|
129
154
|
<section id="go">
|
|
130
155
|
<h2>Go</h2>
|
|
@@ -437,7 +462,7 @@ summary { cursor: pointer; color: var(--muted); }
|
|
|
437
462
|
</article>
|
|
438
463
|
<article id="typescript/no-new-strict-errors">
|
|
439
464
|
<h3><code>typescript/no-new-strict-errors</code></h3>
|
|
440
|
-
<p>Type-checks the project with strictNullChecks and strictPropertyInitialization on, and fails only on the errors the turn added: a project that turned them off, with more errors than it can fix at once, stops growing new ones. An error is told by its file, code and source line, since tsc prints the types of a message otherwise from one compilation to the next: one a change moves to another line is not new, nor one tsc reports with the same message in another file the turn did not change, nor one on a line the turn changed, as long as its file has no more errors of its code than at the turn start. The agent still reads the message. tsc keeps watching between turns; without the watch, it runs at each prompt and stop instead. Refused when tsconfig.json only references others, as in an Angular project, since tsc would check no file: give it -p and a tsconfig. The whole check counts every error.</p>
|
|
465
|
+
<p>Type-checks the project with strictNullChecks and strictPropertyInitialization on, and fails only on the errors the turn added: a project that turned them off, with more errors than it can fix at once, stops growing new ones. An error is told by its file, code and source line, since tsc prints the types of a message otherwise from one compilation to the next: one a change moves to another line is not new, nor one tsc reports with the same message in another file the turn did not change, nor one on a line the turn changed, as long as its file has no more errors of its code than at the turn start. The agent still reads the message. tsc keeps watching between turns; without the watch, it runs at each prompt and stop instead. Refused when tsconfig.json only references others, as in an Angular project, since tsc would check no file: give it -p and a tsconfig. The whole check counts every error. The watch is asked for a cycle through tsconfig.json: with -p, give its watch.sync the same tsconfig.</p>
|
|
441
466
|
<dl>
|
|
442
467
|
<dt>Runs</dt><dd><code>{engine}/src/helpers/type-errors.ts --strictNullChecks --strictPropertyInitialization</code></dd>
|
|
443
468
|
<dt>When the turn changes</dt><dd><code>(\.(ts|tsx)|^tsconfig.*\.json)$</code></dd>
|
|
@@ -462,7 +487,8 @@ summary { cursor: pointer; color: var(--muted); }
|
|
|
462
487
|
"--strictPropertyInitialization"
|
|
463
488
|
],
|
|
464
489
|
"cycleStart": "^Type check started$",
|
|
465
|
-
"cycleEnd": "^Type check done$"
|
|
490
|
+
"cycleEnd": "^Type check done$",
|
|
491
|
+
"sync": "tsconfig.json"
|
|
466
492
|
}
|
|
467
493
|
}</code></pre></details>
|
|
468
494
|
</article>
|
package/catalog/typescript.json
CHANGED
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
}
|
|
97
97
|
},
|
|
98
98
|
{
|
|
99
|
-
"description": "Type-checks the project with strictNullChecks and strictPropertyInitialization on, and fails only on the errors the turn added: a project that turned them off, with more errors than it can fix at once, stops growing new ones. An error is told by its file, code and source line, since tsc prints the types of a message otherwise from one compilation to the next: one a change moves to another line is not new, nor one tsc reports with the same message in another file the turn did not change, nor one on a line the turn changed, as long as its file has no more errors of its code than at the turn start. The agent still reads the message. tsc keeps watching between turns; without the watch, it runs at each prompt and stop instead. Refused when tsconfig.json only references others, as in an Angular project, since tsc would check no file: give it -p and a tsconfig. The whole check counts every error.",
|
|
99
|
+
"description": "Type-checks the project with strictNullChecks and strictPropertyInitialization on, and fails only on the errors the turn added: a project that turned them off, with more errors than it can fix at once, stops growing new ones. An error is told by its file, code and source line, since tsc prints the types of a message otherwise from one compilation to the next: one a change moves to another line is not new, nor one tsc reports with the same message in another file the turn did not change, nor one on a line the turn changed, as long as its file has no more errors of its code than at the turn start. The agent still reads the message. tsc keeps watching between turns; without the watch, it runs at each prompt and stop instead. Refused when tsconfig.json only references others, as in an Angular project, since tsc would check no file: give it -p and a tsconfig. The whole check counts every error. The watch is asked for a cycle through tsconfig.json: with -p, give its watch.sync the same tsconfig.",
|
|
100
100
|
"requires": [
|
|
101
101
|
{
|
|
102
102
|
"tool": "typescript",
|
|
@@ -118,7 +118,8 @@
|
|
|
118
118
|
"--strictPropertyInitialization"
|
|
119
119
|
],
|
|
120
120
|
"cycleStart": "^Type check started$",
|
|
121
|
-
"cycleEnd": "^Type check done$"
|
|
121
|
+
"cycleEnd": "^Type check done$",
|
|
122
|
+
"sync": "tsconfig.json"
|
|
122
123
|
}
|
|
123
124
|
}
|
|
124
125
|
},
|
package/dist/src/core/config.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { join } from "node:path";
|
|
2
|
+
import { isAbsolute, join } from "node:path";
|
|
3
3
|
import { isRecord, isStringArray, messageOf } from "./json.js";
|
|
4
4
|
import { repoRoot } from "./snapshot.js";
|
|
5
5
|
const GATES_FILE = ".gates.json";
|
|
@@ -19,7 +19,7 @@ const FIELDS = new Set([
|
|
|
19
19
|
"timeoutSeconds",
|
|
20
20
|
"watch",
|
|
21
21
|
]);
|
|
22
|
-
const WATCH_FIELDS = new Set(["run", "cycleStart", "cycleEnd", "failed"]);
|
|
22
|
+
const WATCH_FIELDS = new Set(["run", "cycleStart", "cycleEnd", "failed", "sync", "frozen"]);
|
|
23
23
|
/** In the arguments of a gate: the changed files it looks at, and the commit of the turn start. */
|
|
24
24
|
export const FILES = "{files}";
|
|
25
25
|
export const TURN = "{turn}";
|
|
@@ -94,11 +94,11 @@ function isPattern(value) {
|
|
|
94
94
|
}
|
|
95
95
|
function toWatch(watch, compared) {
|
|
96
96
|
if (!isRecord(watch))
|
|
97
|
-
return refuse("watch holds run, cycleStart, cycleEnd and
|
|
97
|
+
return refuse("watch holds run, cycleStart, cycleEnd, failed and sync");
|
|
98
98
|
const unknown = Object.keys(watch).find((key) => !WATCH_FIELDS.has(key));
|
|
99
99
|
if (unknown !== undefined)
|
|
100
100
|
refuse(`unknown field watch.${unknown}`);
|
|
101
|
-
const { run, cycleStart, cycleEnd, failed } = watch;
|
|
101
|
+
const { run, cycleStart, cycleEnd, failed, sync, frozen } = watch;
|
|
102
102
|
if (!isStringArray(run) || !run.length)
|
|
103
103
|
refuse("watch.run is a non-empty list of strings");
|
|
104
104
|
if (run.some((argument) => argument.includes(FILES) || argument.includes(TURN)))
|
|
@@ -106,8 +106,14 @@ function toWatch(watch, compared) {
|
|
|
106
106
|
const pattern = (field, value) => isPattern(value) ? value : refuse(`watch.${field} is a regular expression on a line of its output`);
|
|
107
107
|
if (compared && failed !== undefined)
|
|
108
108
|
refuse("a compared watch fails on the lines its cycle added: no watch.failed");
|
|
109
|
+
if (typeof sync !== "string" || !sync || isAbsolute(sync) || sync.split(/[\\/]/).includes(".."))
|
|
110
|
+
refuse("watch.sync is a file of the repo the watch opens a cycle for when its date changes, such as its tsconfig");
|
|
111
|
+
if (frozen !== undefined && !isPattern(frozen))
|
|
112
|
+
refuse("watch.frozen is a regular expression on the files the watch lists only as it starts");
|
|
109
113
|
return {
|
|
110
114
|
run,
|
|
115
|
+
sync,
|
|
116
|
+
...(frozen === undefined ? {} : { frozen }),
|
|
111
117
|
cycleStart: pattern("cycleStart", cycleStart),
|
|
112
118
|
cycleEnd: pattern("cycleEnd", cycleEnd),
|
|
113
119
|
...(compared ? {} : { failed: pattern("failed", failed) }),
|