quick-gate 0.2.0-alpha.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.
package/LICENSE ADDED
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to the Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by the Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding any notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Hermes Labs (LPCI)
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
189
+ See the License for the specific language governing permissions and
190
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,153 @@
1
+ # Quick Gate
2
+
3
+ Deterministic quality gate CLI for Next.js repositories with bounded auto-repair and explicit escalation evidence.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ # From your Next.js project directory:
9
+ npx quick-gate run --mode canary --changed-files <path-to-changed-files-list>
10
+
11
+ # Or install globally:
12
+ npm install -g quick-gate
13
+ quick-gate --help
14
+ ```
15
+
16
+ Create a changed-files list (newline-delimited or JSON array):
17
+
18
+ ```bash
19
+ echo "app/page.tsx" > /tmp/changed.txt
20
+ quick-gate run --mode canary --changed-files /tmp/changed.txt
21
+ ```
22
+
23
+ ## What It Does
24
+
25
+ Quick Gate runs four deterministic quality gates on your Next.js project:
26
+
27
+ 1. **lint** -- runs your ESLint config
28
+ 2. **typecheck** -- runs TypeScript compiler
29
+ 3. **build** -- runs production build (full mode only)
30
+ 4. **lighthouse** -- runs Lighthouse CI assertions
31
+
32
+ When gates fail, it produces structured evidence (not just exit codes) and optionally runs a bounded repair loop that:
33
+ - Applies deterministic fixes first (eslint --fix on scoped files)
34
+ - Optionally uses local LLM models (via Ollama) for model-assisted patches
35
+ - Enforces hard limits on attempts, patch size, and wall-clock time
36
+ - Escalates with machine-readable evidence when it can't resolve
37
+
38
+ ## Commands
39
+
40
+ ```bash
41
+ # Run quality gates
42
+ quick-gate run --mode canary|full --changed-files <path>
43
+
44
+ # Generate agent brief from failures
45
+ quick-gate summarize --input .quick-gate/failures.json
46
+
47
+ # Bounded repair loop
48
+ quick-gate repair --input .quick-gate/failures.json [--max-attempts 3] [--deterministic-only]
49
+ ```
50
+
51
+ ## Artifacts
52
+
53
+ Generated in your project under `.quick-gate/`:
54
+
55
+ | File | Description |
56
+ |------|-------------|
57
+ | `failures.json` | Structured findings with severity, thresholds, evidence |
58
+ | `run-metadata.json` | Gate execution traces (commands, stdout, stderr) |
59
+ | `agent-brief.json` | Priority actions + retry policy for downstream agents |
60
+ | `agent-brief.md` | Human-readable summary |
61
+ | `repair-report.json` | Repair attempt history (on success) |
62
+ | `escalation.json` | Escalation reason + evidence (when repair fails) |
63
+
64
+ ## Repair Policy
65
+
66
+ | Parameter | Default | Description |
67
+ |-----------|---------|-------------|
68
+ | max attempts | 3 | Total repair attempts before escalation |
69
+ | max patch lines | 150 | Per-attempt patch size budget |
70
+ | no-improvement abort | 2 | Consecutive no-improvement attempts before abort |
71
+ | time cap | 20 min | Wall-clock limit for entire repair loop |
72
+
73
+ Escalation reason codes: `NO_IMPROVEMENT`, `PATCH_BUDGET_EXCEEDED`, `ARCHITECTURAL_CHANGE_REQUIRED`, `FLAKY_EVALUATOR`, `UNKNOWN_BLOCKER`
74
+
75
+ ## Model-Assisted Repair (Optional)
76
+
77
+ Requires [Ollama](https://ollama.ai) installed locally. Without Ollama, Quick Gate still works -- it runs deterministic fixes only and escalates what it can't resolve.
78
+
79
+ With Ollama:
80
+ - **Hint model** (default: `qwen2.5:1.5b`): Generates repair hints
81
+ - **Patch model** (default: `mistral:7b`): Generates scoped edit plans
82
+ - Safety: edit plans are scored for relevance and enforced against patch-line budget before apply
83
+
84
+ Environment overrides:
85
+
86
+ ```bash
87
+ QUICK_GATE_HINT_MODEL=qwen3:4b
88
+ QUICK_GATE_PATCH_MODEL=mistral:7b
89
+ QUICK_GATE_MODEL_TIMEOUT_MS=60000
90
+ QUICK_GATE_ALLOW_HINT_ONLY_PATCH=0
91
+ ```
92
+
93
+ ## GitHub Action
94
+
95
+ Add Quick Gate to any PR workflow with one step:
96
+
97
+ ```yaml
98
+ # .github/workflows/quick-gate.yml
99
+ name: Quick Gate
100
+ on:
101
+ pull_request:
102
+ branches: [main]
103
+ permissions:
104
+ contents: read
105
+ pull-requests: write
106
+ jobs:
107
+ quality-gate:
108
+ runs-on: ubuntu-latest
109
+ steps:
110
+ - uses: actions/checkout@v4
111
+ with:
112
+ fetch-depth: 0
113
+ - run: npm ci
114
+ - uses: roli-lpci/quick-gate/.github/actions/quick-gate@main
115
+ with:
116
+ mode: canary
117
+ repair: "true"
118
+ post-comment: "true"
119
+ ```
120
+
121
+ This will:
122
+ - Detect changed files from the PR diff
123
+ - Run lint, typecheck, and Lighthouse gates
124
+ - Attempt deterministic repair (eslint --fix) on failures
125
+ - Post a structured findings comment on the PR
126
+ - Upload `.quick-gate/` artifacts for inspection
127
+
128
+ No Ollama required -- CI runs in deterministic-only mode by default.
129
+
130
+ ## Configuration
131
+
132
+ Create `quick-gate.config.json` in your project root to override defaults:
133
+
134
+ ```json
135
+ {
136
+ "commands": {
137
+ "lint": "npm run lint",
138
+ "typecheck": "npm run typecheck",
139
+ "build": "npm run build",
140
+ "lighthouse": "npm run ci:lighthouse"
141
+ },
142
+ "policy": {
143
+ "maxAttempts": 3,
144
+ "maxPatchLines": 150,
145
+ "abortOnNoImprovement": 2,
146
+ "timeCapMs": 1200000
147
+ }
148
+ }
149
+ ```
150
+
151
+ ## License
152
+
153
+ Apache 2.0 -- See [LICENSE](LICENSE) for details.
package/package.json ADDED
@@ -0,0 +1,45 @@
1
+ {
2
+ "name": "quick-gate",
3
+ "version": "0.2.0-alpha.1",
4
+ "description": "Deterministic quality gate CLI for Next.js with bounded auto-repair and escalation evidence",
5
+ "type": "module",
6
+ "bin": {
7
+ "quick-gate": "src/cli.js"
8
+ },
9
+ "files": [
10
+ "src/",
11
+ "schemas/"
12
+ ],
13
+ "scripts": {
14
+ "test": "node --test 'test/*.test.js'"
15
+ },
16
+ "engines": {
17
+ "node": ">=18.0.0"
18
+ },
19
+ "license": "Apache-2.0",
20
+ "author": "Hermes Labs <lpcisystems@gmail.com> (https://lpci.ai)",
21
+ "homepage": "https://lpci.ai",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/roli-lpci/quick-gate.git"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/roli-lpci/quick-gate/issues"
28
+ },
29
+ "keywords": [
30
+ "quality-gate",
31
+ "ci",
32
+ "lint",
33
+ "typecheck",
34
+ "lighthouse",
35
+ "nextjs",
36
+ "auto-repair",
37
+ "deterministic",
38
+ "eslint",
39
+ "typescript"
40
+ ],
41
+ "dependencies": {
42
+ "ajv": "^8.17.1",
43
+ "ajv-formats": "^3.0.1"
44
+ }
45
+ }
@@ -0,0 +1,112 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://quick-gate.dev/schemas/agent-brief.schema.json",
4
+ "title": "Quick Gate Agent Brief",
5
+ "type": "object",
6
+ "required": [
7
+ "run_id",
8
+ "mode",
9
+ "status",
10
+ "priority_actions",
11
+ "retry_policy"
12
+ ],
13
+ "properties": {
14
+ "run_id": {
15
+ "type": "string"
16
+ },
17
+ "mode": {
18
+ "type": "string",
19
+ "enum": [
20
+ "canary",
21
+ "full"
22
+ ]
23
+ },
24
+ "status": {
25
+ "type": "string",
26
+ "enum": [
27
+ "pass",
28
+ "fail"
29
+ ]
30
+ },
31
+ "summary": {
32
+ "type": "string"
33
+ },
34
+ "priority_actions": {
35
+ "type": "array",
36
+ "items": {
37
+ "type": "object",
38
+ "required": [
39
+ "finding_id",
40
+ "action",
41
+ "scope",
42
+ "rationale"
43
+ ],
44
+ "properties": {
45
+ "finding_id": {
46
+ "type": "string"
47
+ },
48
+ "action": {
49
+ "type": "string"
50
+ },
51
+ "scope": {
52
+ "type": "string",
53
+ "enum": [
54
+ "single_file",
55
+ "single_route",
56
+ "cross_route"
57
+ ]
58
+ },
59
+ "target_files": {
60
+ "type": "array",
61
+ "items": {
62
+ "type": "string"
63
+ }
64
+ },
65
+ "rationale": {
66
+ "type": "string"
67
+ }
68
+ },
69
+ "additionalProperties": false
70
+ }
71
+ },
72
+ "retry_policy": {
73
+ "type": "object",
74
+ "required": [
75
+ "max_attempts",
76
+ "max_patch_lines",
77
+ "abort_on_no_improvement"
78
+ ],
79
+ "properties": {
80
+ "max_attempts": {
81
+ "type": "integer",
82
+ "minimum": 1
83
+ },
84
+ "max_patch_lines": {
85
+ "type": "integer",
86
+ "minimum": 1
87
+ },
88
+ "abort_on_no_improvement": {
89
+ "type": "integer",
90
+ "minimum": 1
91
+ }
92
+ },
93
+ "additionalProperties": false
94
+ },
95
+ "escalation": {
96
+ "type": "object",
97
+ "properties": {
98
+ "required": {
99
+ "type": "boolean"
100
+ },
101
+ "reason_code": {
102
+ "type": "string"
103
+ },
104
+ "message": {
105
+ "type": "string"
106
+ }
107
+ },
108
+ "additionalProperties": false
109
+ }
110
+ },
111
+ "additionalProperties": false
112
+ }
@@ -0,0 +1,193 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://quick-gate.dev/schemas/failures.schema.json",
4
+ "title": "Quick Gate Failures",
5
+ "type": "object",
6
+ "required": [
7
+ "version",
8
+ "run_id",
9
+ "mode",
10
+ "status",
11
+ "timestamp",
12
+ "gates",
13
+ "findings"
14
+ ],
15
+ "properties": {
16
+ "version": {
17
+ "type": "string"
18
+ },
19
+ "run_id": {
20
+ "type": "string"
21
+ },
22
+ "mode": {
23
+ "type": "string",
24
+ "enum": [
25
+ "canary",
26
+ "full"
27
+ ]
28
+ },
29
+ "status": {
30
+ "type": "string",
31
+ "enum": [
32
+ "pass",
33
+ "fail"
34
+ ]
35
+ },
36
+ "timestamp": {
37
+ "type": "string",
38
+ "format": "date-time"
39
+ },
40
+ "repo": {
41
+ "type": "string"
42
+ },
43
+ "branch": {
44
+ "type": "string"
45
+ },
46
+ "changed_files": {
47
+ "type": "array",
48
+ "items": {
49
+ "type": "string"
50
+ }
51
+ },
52
+ "gates": {
53
+ "type": "array",
54
+ "items": {
55
+ "type": "object",
56
+ "required": [
57
+ "name",
58
+ "status"
59
+ ],
60
+ "properties": {
61
+ "name": {
62
+ "type": "string",
63
+ "enum": [
64
+ "lint",
65
+ "typecheck",
66
+ "build",
67
+ "lighthouse"
68
+ ]
69
+ },
70
+ "status": {
71
+ "type": "string",
72
+ "enum": [
73
+ "pass",
74
+ "fail",
75
+ "skipped"
76
+ ]
77
+ },
78
+ "duration_ms": {
79
+ "type": "integer",
80
+ "minimum": 0
81
+ }
82
+ },
83
+ "additionalProperties": false
84
+ }
85
+ },
86
+ "findings": {
87
+ "description": "Deterministic findings only. No inferred causes here.",
88
+ "type": "array",
89
+ "items": {
90
+ "type": "object",
91
+ "required": [
92
+ "id",
93
+ "gate",
94
+ "severity",
95
+ "summary",
96
+ "actual",
97
+ "threshold",
98
+ "status"
99
+ ],
100
+ "properties": {
101
+ "id": {
102
+ "type": "string"
103
+ },
104
+ "gate": {
105
+ "type": "string",
106
+ "enum": [
107
+ "lint",
108
+ "typecheck",
109
+ "build",
110
+ "lighthouse"
111
+ ]
112
+ },
113
+ "severity": {
114
+ "type": "string",
115
+ "enum": [
116
+ "low",
117
+ "medium",
118
+ "high",
119
+ "critical"
120
+ ]
121
+ },
122
+ "summary": {
123
+ "type": "string"
124
+ },
125
+ "route": {
126
+ "type": "string"
127
+ },
128
+ "files": {
129
+ "type": "array",
130
+ "items": {
131
+ "type": "string"
132
+ }
133
+ },
134
+ "metric": {
135
+ "type": "string"
136
+ },
137
+ "actual": {
138
+ "type": [
139
+ "number",
140
+ "string"
141
+ ]
142
+ },
143
+ "threshold": {
144
+ "type": [
145
+ "number",
146
+ "string"
147
+ ]
148
+ },
149
+ "status": {
150
+ "type": "string",
151
+ "enum": [
152
+ "fail"
153
+ ]
154
+ },
155
+ "raw": {
156
+ "type": "object"
157
+ }
158
+ },
159
+ "additionalProperties": false
160
+ }
161
+ },
162
+ "inferred_hints": {
163
+ "description": "Optional model-generated hints; never treated as source of truth.",
164
+ "type": "array",
165
+ "items": {
166
+ "type": "object",
167
+ "required": [
168
+ "finding_id",
169
+ "hint",
170
+ "confidence"
171
+ ],
172
+ "properties": {
173
+ "finding_id": {
174
+ "type": "string"
175
+ },
176
+ "hint": {
177
+ "type": "string"
178
+ },
179
+ "confidence": {
180
+ "type": "string",
181
+ "enum": [
182
+ "low",
183
+ "medium",
184
+ "high"
185
+ ]
186
+ }
187
+ },
188
+ "additionalProperties": false
189
+ }
190
+ }
191
+ },
192
+ "additionalProperties": false
193
+ }