gatecheck 0.0.1-beta.5
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 +311 -0
- package/dist/bin.mjs +722 -0
- package/dist/setup-BGSEp6JC.mjs +441 -0
- package/package.json +51 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 d-kimuson
|
|
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
ADDED
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
# gatecheck
|
|
2
|
+
|
|
3
|
+
Quality gate for git changes — run deterministic checks and AI-powered reviews against changed files.
|
|
4
|
+
|
|
5
|
+
In AI-native workflows, agents produce large volumes of code changes. Compound guardrails — type checking, linting, testing — let agents receive automated feedback and self-correct in a tight loop. gatecheck makes this simple: run `gatecheck check` and it executes your configured checks, scoped to only the files that changed. Run `gatecheck review` to get AI-powered code reviews on the same changed files.
|
|
6
|
+
|
|
7
|
+
Designed for AI agent integration. Ships with built-in support for [Claude Code hooks](https://docs.anthropic.com/en/docs/claude-code/hooks) and [Copilot CLI hooks](https://docs.github.com/en/copilot/reference/cli-command-reference#agentstop--subagentstop-decision-control).
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm add -D gatecheck
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
Run the interactive setup to generate a `gatecheck.yaml` config file:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
pnpm gatecheck setup
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The setup wizard walks you through:
|
|
24
|
+
|
|
25
|
+
1. **Default changed sources** — Which changed files to check (default: `untracked,unstaged,staged,branch:main`).
|
|
26
|
+
2. **Default target groups** — Which check groups to run (default: `all`).
|
|
27
|
+
3. **Check presets** — Detects installed dependencies and pre-selects matching presets (prettier, oxfmt, eslint, oxlint, biome, tsc, tsgo, vitest, jest).
|
|
28
|
+
4. **Review preset** — Optionally add an AI review (codex or claude).
|
|
29
|
+
5. **Agent hooks** — Optionally configure Claude Code Stop hooks or Copilot CLI agentStop hooks.
|
|
30
|
+
|
|
31
|
+
For non-interactive setup (CI, scripts):
|
|
32
|
+
|
|
33
|
+
```sh
|
|
34
|
+
pnpm gatecheck setup --non-interactive
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Commands
|
|
38
|
+
|
|
39
|
+
### `gatecheck check`
|
|
40
|
+
|
|
41
|
+
Run deterministic checks (lint, typecheck, test, format) against changed files.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
# Run all checks with config defaults
|
|
45
|
+
pnpm gatecheck check
|
|
46
|
+
|
|
47
|
+
# Specify changed sources and target groups
|
|
48
|
+
pnpm gatecheck check --changed staged --target lint,typecheck
|
|
49
|
+
|
|
50
|
+
# Preview which checks would run
|
|
51
|
+
pnpm gatecheck check --dry-run
|
|
52
|
+
|
|
53
|
+
# Machine-readable output
|
|
54
|
+
pnpm gatecheck check --format json
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
**Options:**
|
|
58
|
+
|
|
59
|
+
| Flag | Description |
|
|
60
|
+
| ------------------------- | --------------------------------------------------------------------------------- |
|
|
61
|
+
| `-c, --changed <sources>` | Changed sources (comma-separated). See [Changed Sources](#changed-sources) |
|
|
62
|
+
| `-t, --target <groups>` | Target groups (comma-separated or `"all"`) |
|
|
63
|
+
| `-d, --dry-run` | Show which checks would run without executing |
|
|
64
|
+
| `-f, --format <format>` | Output format: `text` (default), `json`, `claude-code-hooks`, `copilot-cli-hooks` |
|
|
65
|
+
|
|
66
|
+
### `gatecheck review`
|
|
67
|
+
|
|
68
|
+
Run AI-powered code reviews against changed files.
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
# Run all configured reviews
|
|
72
|
+
pnpm gatecheck review
|
|
73
|
+
|
|
74
|
+
# Preview review configuration
|
|
75
|
+
pnpm gatecheck review --dry-run
|
|
76
|
+
|
|
77
|
+
# Review changes since main branch
|
|
78
|
+
pnpm gatecheck review --changed branch:main
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Options:**
|
|
82
|
+
|
|
83
|
+
| Flag | Description |
|
|
84
|
+
| ------------------------- | ------------------------------------------------------ |
|
|
85
|
+
| `-c, --changed <sources>` | Changed sources (comma-separated) |
|
|
86
|
+
| `-d, --dry-run` | Show review config and matched files without executing |
|
|
87
|
+
|
|
88
|
+
### `gatecheck setup`
|
|
89
|
+
|
|
90
|
+
Create or update `gatecheck.yaml` interactively.
|
|
91
|
+
|
|
92
|
+
| Flag | Description |
|
|
93
|
+
| ------------------- | --------------------------------------------------- |
|
|
94
|
+
| `--non-interactive` | Skip prompts, auto-detect presets from package.json |
|
|
95
|
+
|
|
96
|
+
## Configuration
|
|
97
|
+
|
|
98
|
+
All configuration lives in `gatecheck.yaml` at your project root.
|
|
99
|
+
|
|
100
|
+
```yaml
|
|
101
|
+
defaults:
|
|
102
|
+
changed: untracked,unstaged,staged,branch:main
|
|
103
|
+
target: all
|
|
104
|
+
|
|
105
|
+
checks:
|
|
106
|
+
- name: typecheck
|
|
107
|
+
match: '\.(m|c)?tsx?$'
|
|
108
|
+
group: typecheck
|
|
109
|
+
command: pnpm exec tsc --noEmit
|
|
110
|
+
|
|
111
|
+
- name: eslint
|
|
112
|
+
match: '\.(m|c)?(j|t)sx?$'
|
|
113
|
+
group: lint
|
|
114
|
+
command: pnpm exec eslint {{ ctx.CHANGED_FILES }}
|
|
115
|
+
|
|
116
|
+
reviews:
|
|
117
|
+
- name: claude-review
|
|
118
|
+
match: '.*'
|
|
119
|
+
exclude: '**/*.md'
|
|
120
|
+
vars:
|
|
121
|
+
prompt: |
|
|
122
|
+
Changed files: {{ ctx.CHANGED_FILES }}
|
|
123
|
+
|
|
124
|
+
You are a professional software architect.
|
|
125
|
+
Please review the changes above.
|
|
126
|
+
Point out any design issues, bug risks, or improvements.
|
|
127
|
+
command: claude --permission-mode 'auto' -p {{ vars.prompt }}
|
|
128
|
+
fallbacks:
|
|
129
|
+
- codex exec --sandbox 'workspace-write' {{ vars.prompt }}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
### Config Reference
|
|
133
|
+
|
|
134
|
+
**defaults** (optional)
|
|
135
|
+
|
|
136
|
+
| Field | Type | Description |
|
|
137
|
+
| --------- | ------ | -------------------------------------------------- |
|
|
138
|
+
| `changed` | string | Default changed sources (comma-separated) |
|
|
139
|
+
| `target` | string | Default target groups (comma-separated or `"all"`) |
|
|
140
|
+
|
|
141
|
+
**checks[]**
|
|
142
|
+
|
|
143
|
+
| Field | Type | Required | Description |
|
|
144
|
+
| ------------------------ | ------ | -------- | ------------------------------------------------- |
|
|
145
|
+
| `name` | string | yes | Unique check identifier |
|
|
146
|
+
| `match` | string | yes | Regex pattern matched against relative file paths |
|
|
147
|
+
| `exclude` | string | no | Glob pattern to exclude matched files |
|
|
148
|
+
| `group` | string | yes | Group name for `--target` filtering |
|
|
149
|
+
| `command` | string | yes | Shell command to execute (supports templates) |
|
|
150
|
+
| `changedFiles.separator` | string | no | Separator between file paths (default: `" "`) |
|
|
151
|
+
| `changedFiles.path` | string | no | `"relative"` (default) or `"absolute"` |
|
|
152
|
+
|
|
153
|
+
**reviews[]**
|
|
154
|
+
|
|
155
|
+
| Field | Type | Required | Description |
|
|
156
|
+
| ----------- | -------- | -------- | -------------------------------------------------- |
|
|
157
|
+
| `name` | string | yes | Unique review identifier |
|
|
158
|
+
| `match` | string | yes | Regex pattern matched against relative file paths |
|
|
159
|
+
| `exclude` | string | no | Glob pattern to exclude matched files |
|
|
160
|
+
| `vars` | map | no | Template variables (can reference env, match, ctx) |
|
|
161
|
+
| `command` | string | yes | Primary command to execute |
|
|
162
|
+
| `fallbacks` | string[] | no | Fallback commands tried in order if primary fails |
|
|
163
|
+
|
|
164
|
+
## Template Engine
|
|
165
|
+
|
|
166
|
+
Commands and vars support `{{ scope.KEY }}` template syntax.
|
|
167
|
+
|
|
168
|
+
### Scopes
|
|
169
|
+
|
|
170
|
+
| Scope | Description | Example |
|
|
171
|
+
| ------- | -------------------------- | ------------------------- |
|
|
172
|
+
| `env` | Environment variables | `{{ env.HOME }}` |
|
|
173
|
+
| `match` | Regex named capture groups | `{{ match.workspace }}` |
|
|
174
|
+
| `ctx` | Runtime context | `{{ ctx.CHANGED_FILES }}` |
|
|
175
|
+
| `vars` | User-defined variables | `{{ vars.prompt }}` |
|
|
176
|
+
|
|
177
|
+
### Context Variables
|
|
178
|
+
|
|
179
|
+
| Variable | Available in | Description |
|
|
180
|
+
| ------------------- | --------------- | ----------------------------------------------------------------------------- |
|
|
181
|
+
| `ctx.CHANGED_FILES` | checks, reviews | Space-separated matched file paths. Shell-escaped in checks; plain in reviews |
|
|
182
|
+
| `ctx.DIFF_SUMMARY` | reviews only | Full git diff output for review context |
|
|
183
|
+
|
|
184
|
+
### Shell Escaping
|
|
185
|
+
|
|
186
|
+
In **check commands**, `{{ ctx.CHANGED_FILES }}` contains individually shell-escaped paths (e.g., `'src/file.ts' 'src/other.ts'`), safe for direct use as shell arguments.
|
|
187
|
+
|
|
188
|
+
In **review commands**, `{{ ctx.CHANGED_FILES }}` contains plain paths (for human-readable prompts). When `{{ vars.* }}` values are substituted into review commands, they are automatically shell-escaped with single quotes. This means you should **not** manually quote `{{ vars.prompt }}` in your command:
|
|
189
|
+
|
|
190
|
+
```yaml
|
|
191
|
+
# Correct — vars are auto-escaped
|
|
192
|
+
command: claude -p {{ vars.prompt }}
|
|
193
|
+
|
|
194
|
+
# Wrong — double-quoting breaks the command
|
|
195
|
+
command: claude -p '{{ vars.prompt }}'
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## Changed Sources
|
|
199
|
+
|
|
200
|
+
Values for `defaults.changed` and the `--changed` CLI option:
|
|
201
|
+
|
|
202
|
+
| Value | Description |
|
|
203
|
+
| --------------- | ------------------------------------- |
|
|
204
|
+
| `untracked` | New files not yet tracked by git |
|
|
205
|
+
| `unstaged` | Modified but not staged |
|
|
206
|
+
| `staged` | Staged for commit |
|
|
207
|
+
| `branch:<name>` | Changes since branching from `<name>` |
|
|
208
|
+
| `sha:<sha>` | Changes since a specific commit |
|
|
209
|
+
|
|
210
|
+
Multiple sources are comma-separated. Changes from all specified sources are combined and deduplicated.
|
|
211
|
+
|
|
212
|
+
Default (when not specified): `unstaged,staged`.
|
|
213
|
+
|
|
214
|
+
## Patterns
|
|
215
|
+
|
|
216
|
+
### Named Capture Groups (Monorepo)
|
|
217
|
+
|
|
218
|
+
Use regex named capture groups to run commands per workspace:
|
|
219
|
+
|
|
220
|
+
```yaml
|
|
221
|
+
checks:
|
|
222
|
+
- name: typecheck
|
|
223
|
+
match: '^packages/(?<workspace>[^/]+)/.*\.(m|c)?tsx?$'
|
|
224
|
+
group: typecheck
|
|
225
|
+
command: pnpm --filter {{ match.workspace }} typecheck
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
If `packages/app/src/index.ts` and `packages/lib/src/utils.ts` are both changed, the check runs once per workspace: `typecheck[app]` and `typecheck[lib]`.
|
|
229
|
+
|
|
230
|
+
### Exclude Patterns
|
|
231
|
+
|
|
232
|
+
Use glob patterns to exclude files from matching:
|
|
233
|
+
|
|
234
|
+
```yaml
|
|
235
|
+
reviews:
|
|
236
|
+
- name: review
|
|
237
|
+
match: '.*'
|
|
238
|
+
exclude: '**/*.{test,spec}.{ts,tsx,js,jsx}'
|
|
239
|
+
command: claude -p {{ vars.prompt }}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## AI Agent Integration
|
|
243
|
+
|
|
244
|
+
### As a guardrail in context
|
|
245
|
+
|
|
246
|
+
Add a completion check to your `CLAUDE.md` (or equivalent):
|
|
247
|
+
|
|
248
|
+
````markdown
|
|
249
|
+
## Completion Criteria
|
|
250
|
+
|
|
251
|
+
Before completing the task, run and fix any errors:
|
|
252
|
+
|
|
253
|
+
```sh
|
|
254
|
+
pnpm gatecheck check
|
|
255
|
+
```
|
|
256
|
+
````
|
|
257
|
+
|
|
258
|
+
### Claude Code Hooks
|
|
259
|
+
|
|
260
|
+
Add a `Stop` hook to `.claude/settings.json` — when any check fails, Claude is blocked from stopping:
|
|
261
|
+
|
|
262
|
+
```json
|
|
263
|
+
{
|
|
264
|
+
"hooks": {
|
|
265
|
+
"Stop": [
|
|
266
|
+
{
|
|
267
|
+
"matcher": "",
|
|
268
|
+
"hooks": [
|
|
269
|
+
{
|
|
270
|
+
"type": "command",
|
|
271
|
+
"command": "pnpm gatecheck check --format claude-code-hooks"
|
|
272
|
+
}
|
|
273
|
+
]
|
|
274
|
+
}
|
|
275
|
+
]
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Copilot CLI Hooks
|
|
281
|
+
|
|
282
|
+
Add an `agentStop` hook to `.github/hooks/gatecheck.json`:
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"version": 1,
|
|
287
|
+
"hooks": {
|
|
288
|
+
"agentStop": [
|
|
289
|
+
{
|
|
290
|
+
"type": "command",
|
|
291
|
+
"bash": "pnpm gatecheck check --format copilot-cli-hooks"
|
|
292
|
+
}
|
|
293
|
+
]
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
Both formats output nothing on success (agent stops normally) and `{ "decision": "block", "reason": "..." }` on failure (agent continues fixing).
|
|
299
|
+
|
|
300
|
+
### Output Formats
|
|
301
|
+
|
|
302
|
+
| Format | Use case |
|
|
303
|
+
| ------------------- | -------------------------------------------- |
|
|
304
|
+
| `text` | Human-readable terminal output (default) |
|
|
305
|
+
| `json` | Machine-readable structured output for CI/CD |
|
|
306
|
+
| `claude-code-hooks` | Claude Code Stop hook integration |
|
|
307
|
+
| `copilot-cli-hooks` | Copilot CLI agentStop hook integration |
|
|
308
|
+
|
|
309
|
+
## License
|
|
310
|
+
|
|
311
|
+
MIT
|