|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Commands |
| 4 | + |
| 5 | +- `npm install` -- Install dependencies |
| 6 | +- `node --test test/*.test.js` -- Run all 44 tests |
| 7 | +- `node --test test/gates.test.js` -- Single test file |
| 8 | +- `npm run test` -- Same as above via npm script |
| 9 | +- `npx quick-gate run` -- Run all quality gates |
| 10 | +- `npx quick-gate repair --max-attempts 3` -- Auto-fix lint failures |
| 11 | +- `npx quick-gate summarize` -- Generate agent brief |
| 12 | + |
| 13 | +## Testing |
| 14 | + |
| 15 | +- Framework: Node.js built-in test runner (`node:test` + `node:assert`) |
| 16 | +- Test location: `test/`, named `*.test.js` |
| 17 | +- All tests run offline — subprocess execution is mocked |
| 18 | +- No test framework dependency — uses Node 18+ native test runner |
| 19 | +- Run single test: `node --test test/gates.test.js` |
| 20 | + |
| 21 | +## Project Structure |
| 22 | + |
| 23 | +``` |
| 24 | +src/ |
| 25 | + cli.js # Entry point, argument parsing, subcommand dispatch |
| 26 | + run-command.js # `quick-gate run` — orchestrates gate execution |
| 27 | + repair-command.js # `quick-gate repair` — bounded auto-fix loop |
| 28 | + summarize-command.js # `quick-gate summarize` — agent brief generation |
| 29 | + gates.js # Gate implementations (lint, typecheck, test, lighthouse) |
| 30 | + schema.js # AJV-based JSON schema validation |
| 31 | + model-adapter.js # LLM model adapter for summarize command |
| 32 | + config.js # Config loading (quick-gate.config.js / package.json) |
| 33 | + constants.js # Exit codes, default policy, escalation codes |
| 34 | + exec.js # Child process execution wrapper |
| 35 | + env-check.js # Environment detection (CI, tool availability) |
| 36 | + fs-utils.js # File operations (artifact writes to .quick-gate/) |
| 37 | + deterministic-prefix.js # Deterministic lint fix prefix generation |
| 38 | +schemas/ |
| 39 | + failures.schema.json # JSON schema for gate failure output |
| 40 | + agent-brief.schema.json # JSON schema for summarize output |
| 41 | +test/ # Tests (node:test) |
| 42 | +scripts/ # Benchmark scripts (not published to npm) |
| 43 | +``` |
| 44 | + |
| 45 | +Gate resolution: reads `package.json` scripts → matches gate name → falls back to defaults (e.g., `npx tsc --noEmit` for typecheck). |
| 46 | + |
| 47 | +## Code Style |
| 48 | + |
| 49 | +- ESM modules (`import`/`export`, `"type": "module"` in package.json) |
| 50 | +- Node 18+ only — use `node:` protocol for builtins (`node:fs`, `node:path`, etc.) |
| 51 | +- No TypeScript — plain JavaScript with JSDoc comments where helpful |
| 52 | +- Two runtime dependencies only: `ajv` + `ajv-formats` (schema validation) |
| 53 | +- Version read dynamically from package.json via `createRequire`: |
| 54 | + |
| 55 | +Good: |
| 56 | +```js |
| 57 | +import { createRequire } from 'node:module'; |
| 58 | +const require = createRequire(import.meta.url); |
| 59 | +const { version } = require('../package.json'); |
| 60 | +``` |
| 61 | +
|
| 62 | +Bad: |
| 63 | +```js |
| 64 | +// No hardcoded versions |
| 65 | +const VERSION = '0.2.0'; |
| 66 | + |
| 67 | +// No CommonJS |
| 68 | +const fs = require('fs'); |
| 69 | +``` |
| 70 | +
|
| 71 | +Function and file naming: kebab-case for filenames (`run-command.js`), camelCase for functions (`resolveGateCommand`). |
| 72 | +
|
| 73 | +## Git Workflow |
| 74 | +
|
| 75 | +- Branch from `main` |
| 76 | +- Conventional commits: `feat:`, `fix:`, `test:`, `docs:`, `chore:` |
| 77 | +- Run `node --test test/*.test.js` before pushing |
| 78 | +- JSON schemas in `schemas/` must stay in sync with validation logic in `schema.js` |
| 79 | +
|
| 80 | +## Boundaries |
| 81 | +
|
| 82 | +**Always:** |
| 83 | +- Run tests after modifying source files |
| 84 | +- Use ESM imports with `node:` protocol for builtins |
| 85 | +- Maintain Node 18 compatibility |
| 86 | +- Keep runtime deps minimal (ajv + ajv-formats only) |
| 87 | +- Write artifacts to `.quick-gate/` directory |
| 88 | +
|
| 89 | +**Ask first:** |
| 90 | +- Adding new runtime dependencies |
| 91 | +- Adding new gate types |
| 92 | +- Changing escalation codes in `constants.js` |
| 93 | +- Modifying the repair loop policy defaults |
| 94 | +- Changing artifact output format (breaks downstream consumers) |
| 95 | +
|
| 96 | +**Never:** |
| 97 | +- Use CommonJS `require()` in source files (except `createRequire` for JSON imports) |
| 98 | +- Add TypeScript compilation — this is intentionally plain JS |
| 99 | +- Execute real subprocesses in tests |
| 100 | +- Commit `.quick-gate/` output directory |
| 101 | +- Break JSON schema backward compatibility without a version bump |
0 commit comments