@nolans01/agent-validator 0.1.0 → 0.2.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/README.md CHANGED
@@ -23,6 +23,18 @@ Or as a dev dependency in your project:
23
23
  npm install --save-dev @nolans01/agent-validator
24
24
  ```
25
25
 
26
+ A local install puts the `validator` binary in `node_modules/.bin`, which is not on
27
+ your shell PATH. Invoke it through your package manager's runner:
28
+
29
+ ```bash
30
+ npx validator doctor # npm
31
+ pnpm exec validator doctor # pnpm
32
+ yarn validator doctor # yarn
33
+ ```
34
+
35
+ The examples below use the bare `validator` command, which assumes the global
36
+ install. With a local install, prefix them accordingly.
37
+
26
38
  ## External Tools
27
39
 
28
40
  agent-validator orchestrates external tools. Install the ones you need:
@@ -38,6 +50,7 @@ pip install lizard
38
50
  # Security
39
51
  pip install semgrep
40
52
  brew install gitleaks # or: https://github.com/gitleaks/gitleaks
53
+ gem install brakeman # Rails-specific security checks
41
54
 
42
55
  # Architecture
43
56
  npm install -g madge jscpd knip
@@ -54,6 +67,67 @@ Check which tools are available:
54
67
  validator doctor
55
68
  ```
56
69
 
70
+ ## Docker
71
+
72
+ To avoid installing anything into the project you want to analyze, use the image,
73
+ which ships every external tool preinstalled:
74
+
75
+ ```bash
76
+ docker build -t agent-validator .
77
+ ```
78
+
79
+ Mount the project you want to analyze at `/workspace`:
80
+
81
+ ```bash
82
+ docker run --rm -v "$PWD:/workspace" agent-validator doctor
83
+ docker run --rm -v "$PWD:/workspace" agent-validator scan --gates complexity,security
84
+ ```
85
+
86
+ On PowerShell the mount is written `-v "${PWD}:/workspace"`. The entrypoint is
87
+ `validator`, so pass subcommands directly; the default is `scan`.
88
+
89
+ ### Gates that need the project's own dependencies
90
+
91
+ `type_safety` (tsc), `architecture` (madge, knip) and `test_quality` (stryker)
92
+ resolve imports through the analyzed project's `node_modules`. A `node_modules`
93
+ directory installed on a Windows or macOS host is not reliably readable inside
94
+ the Linux container — pnpm in particular relies on symlinks that do not survive
95
+ the crossing. Shadow it with a container-local volume and install inside:
96
+
97
+ ```bash
98
+ docker run --rm \
99
+ -v "$PWD:/workspace" -v /workspace/node_modules \
100
+ --entrypoint sh agent-validator \
101
+ -c "pnpm install --frozen-lockfile && validator scan"
102
+ ```
103
+
104
+ Gates that only read source text work against a plain mount: `complexity`
105
+ (lizard), `security` (semgrep, gitleaks) and duplication detection (jscpd).
106
+
107
+ ### Network access
108
+
109
+ The `security` gate needs network access. semgrep resolves the `p/...` rule packs
110
+ against semgrep.dev on every invocation and keeps no reusable offline cache, so
111
+ running with `--network none` makes Semgrep fail and the security gate fail closed.
112
+ Every other gate runs fully offline.
113
+
114
+ ### File ownership
115
+
116
+ The image runs as uid 1000. Tools that write into the project — stryker's
117
+ `reports/`, mutmut's cache — will produce files owned by that uid. If your host
118
+ user differs, pass `--user "$(id -u):$(id -g)"`.
119
+
120
+ ### Ruby support
121
+
122
+ The Rails image includes Ruby syntax checks, Brakeman, and Mutant. Mutant
123
+ requires an explicit usage policy and a compatible project bundle; closed-source
124
+ projects normally require a commercial licence. To include the Ruby tools in
125
+ the general image:
126
+
127
+ ```bash
128
+ docker build --build-arg INSTALL_RUBY_TOOLS=true -t agent-validator .
129
+ ```
130
+
57
131
  ## Quick Start
58
132
 
59
133
  ### CLI Usage
@@ -94,6 +168,32 @@ JSON output for CI:
94
168
  validator scan --format json
95
169
  ```
96
170
 
171
+ Write a complete ANSI-free report to a file. Parent directories are created
172
+ automatically and an existing file is replaced:
173
+
174
+ ```bash
175
+ validator scan --output reports/review.txt
176
+ validator scan --format json --output reports/review.json
177
+ ```
178
+
179
+ Run a project-defined test entry point as a baseline instead of assuming a
180
+ framework command:
181
+
182
+ ```bash
183
+ validator dir app lib \
184
+ --gates test_quality \
185
+ --test-command ./rspec.sh \
186
+ --test-timeout 1200000 \
187
+ --output reports/test-quality.txt
188
+ ```
189
+
190
+ The command runs from the analyzed project root. A non-zero exit becomes a
191
+ blocker; a successful baseline without mutation testing produces `warn`, not a
192
+ fabricated 100% mutation score. This supports repositories whose scripts build Docker images,
193
+ start databases, or configure non-standard test libraries. If the script writes
194
+ its own detailed logs, those remain the source for raw test output; `--output`
195
+ stores the normalized validator report.
196
+
97
197
  Fail on warnings (default: fail on blockers only):
98
198
 
99
199
  ```bash
@@ -174,10 +274,13 @@ end
174
274
  - **Fail threshold**: score < 70 OR any blocker (CCN > 1.5× threshold)
175
275
 
176
276
  ### 3. Security Gate
177
- - **Tools**: `semgrep` (SAST), `gitleaks` (secret detection)
277
+ - **Tools**: `semgrep` (SAST), `gitleaks` (secret detection), `brakeman` (Rails)
178
278
  - **Scoring**: -25 per blocker, -10 per warning, -3 per info
179
279
  - **Fail threshold**: score < 70 OR any blocker
180
280
 
281
+ Gitleaks scans the complete checkout, including configuration, documentation,
282
+ shell, YAML, and dotenv files; it is not restricted to source extensions.
283
+
181
284
  ### 4. Architecture Gate
182
285
  - **Tools**: `madge` (circular deps), `jscpd` (duplication), `knip` (dead code)
183
286
  - **Scoring**: -15 per blocker, -7 per warning, -3 per info
@@ -187,8 +290,20 @@ end
187
290
  - **TypeScript/JavaScript**: `stryker`
188
291
  - **Python**: `mutmut`
189
292
  - **Ruby**: `mutant`
293
+ - **Custom project runner**: `--test-command`, for example `./rspec.sh`
190
294
  - **Scoring**: mutation score (% of killed mutants)
191
- - **Fail threshold**: score < 70
295
+ - **Fail threshold**: the active profile's mutation threshold
296
+
297
+ For Rails, `type_safety` first runs `ruby -c` on selected files and then runs
298
+ `RAILS_ENV=test bundle exec rails zeitwerk:check` when Rails and Bundler are
299
+ available. A missing runtime is reported as `skip`, and skipped gates make the
300
+ overall result `warn` rather than a false `pass`.
301
+
302
+ Mutant runs through `bundle exec`, includes both `app` and `lib`, loads the Rails
303
+ environment, and requires `--mutant-usage opensource|commercial`. Timeouts,
304
+ missing policy, empty output, and unparseable output fail closed.
305
+ The project must declare compatible `mutant` and `mutant-rspec` gems in its
306
+ `Gemfile`; a global installation is not considered bundle availability.
192
307
 
193
308
  ## Profiles
194
309