@blundergoat/gruff-ts 0.2.0 → 0.3.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/CHANGELOG.md +24 -0
- package/README.md +80 -12
- package/docs/README.md +2 -0
- package/docs/agent-hook.md +80 -0
- package/docs/ci-integration.md +16 -0
- package/docs/configuration.md +21 -2
- package/docs/output-formats.md +10 -0
- package/docs/philosophy.md +21 -0
- package/docs/releasing.md +5 -5
- package/docs/rules.md +24 -15
- package/package.json +5 -5
- package/scripts/bump-version.sh +1 -1
- package/src/analyser.ts +43 -30
- package/src/blocks.ts +20 -67
- package/src/changed-regions.ts +390 -0
- package/src/check-ignore.ts +49 -0
- package/src/class-rules.ts +80 -33
- package/src/cli-program.ts +105 -11
- package/src/comment-rules.ts +4 -0
- package/src/config-parse.ts +458 -0
- package/src/config-preservation.ts +1 -1
- package/src/config.ts +215 -460
- package/src/constants.ts +1 -1
- package/src/context-doc-rules.ts +2 -4
- package/src/dashboard.ts +7 -4
- package/src/discovery.ts +88 -32
- package/src/findings-helpers.ts +41 -5
- package/src/fixtures/rule-catalogue-security-doctrine.ts +28 -0
- package/src/init-config.ts +3 -0
- package/src/naming-pushers.ts +35 -6
- package/src/profiles.ts +232 -0
- package/src/project-config-rules.ts +5 -5
- package/src/project-rules.ts +2 -1
- package/src/report-html.ts +1 -1
- package/src/report-renderers.ts +58 -0
- package/src/rule-list.ts +22 -1
- package/src/rules.ts +10 -10
- package/src/safety-rules.ts +16 -6
- package/src/scoring.ts +43 -5
- package/src/security-flow-rules.ts +533 -0
- package/src/sensitive-data-rules.ts +138 -2
- package/src/test-block-rules.ts +106 -15
- package/src/test-fixtures.ts +46 -8
- package/src/types.ts +78 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## v0.3.0 - 2026-05-30
|
|
4
|
+
|
|
5
|
+
0.3.0 release. Changes since 0.2.0: three breaking rule removals (`complexity.npath`; `size.stylesheet-length` with CSS dropped from scanned file types; and the `design.god-function` composite), region-scoped incremental analysis, authoritative `paths.ignore` with a new `check-ignore` command, sensitive-data PHI/GCP detection, named config profiles with `extends:` inheritance, and a documentation reframe around gruff's purpose - governing AI-generated code so a human who did not write it can sign off on it.
|
|
6
|
+
|
|
7
|
+
- **BREAKING: removed `complexity.npath`** - the rule and its `approximateNpath` helper are deleted; the complexity pillar is now `cognitive` + `cyclomatic`. Its `2^(decision tokens)` model false-flagged flat switches and guard-chains (easy-to-verify code) and its remediation pushed agents to fragment legible dispatch, while `cognitive` already covers genuine complexity (ADR-005, ADR-006). The `docs.missing-why-for-complex-code` gate drops its npath term (now size/cyclomatic/cognitive/nesting). No schema change (`gruff.analysis.v2` unchanged), but `list-rules`, reports, and findings no longer include `complexity.npath`, and a stale `rules.complexity.npath.*` config block is silently ignored. (`src/rules.ts`, `src/blocks.ts`, `src/context-doc-rules.ts`)
|
|
8
|
+
- **BREAKING: removed `size.stylesheet-length` and dropped CSS from scanned file types** - `.css` files are no longer discovered or analysed, and the CSS-only `size.stylesheet-length` rule (with its `isCssPath` gate) is deleted; the `size` pillar drops to 3. The rule could only ever fire on `.css` files, so dropping CSS scanning left it dead - same shape as the npath removal. No schema change (`gruff.analysis.v2` unchanged), but `list-rules`, reports, and findings no longer include `size.stylesheet-length`, and a stale `rules.size.stylesheet-length.*` config block is silently ignored. (`src/discovery.ts`, `src/analyser.ts`, `src/rules.ts`, `.gruff-ts.yaml`)
|
|
9
|
+
- **BREAKING: removed the `design.god-function` composite** - the rule and its `pushGodFunctionFinding` emitter are deleted; the `design` pillar drops from 6 to 5 and the catalogue from 120 to 119 (still 11 pillars). It fired only when a function was both long (>45 lines) and complex (cyclomatic >10) - a synthetic restatement of the `size.function-length` + `complexity.*` findings already on that symbol, whose only honest score is neutral once ADR-009 clusters those findings into one penalty. `design.god-function` is dropped from `CORRELATED_COMPLEXITY_RULE_IDS` while `complexity.cognitive`, `complexity.cyclomatic`, and `size.function-length` stay, so a long-and-complex function still moves the grade once with every finding listed - P5 now rests on that clustering, not on a named composite. Family-wide retirement of the `design.god-*` composite (gruff-rs removed it first); the named god-function signal is the only loss. No schema change (`gruff.analysis.v2` unchanged), but `list-rules`, reports, and findings no longer include `design.god-function`, and a stale `rules.design.god-function.*` config block is silently ignored. (ADR-011, ADR-009; `src/rules.ts`, `src/blocks.ts`, `src/scoring.ts`, `src/report-renderers.ts`)
|
|
10
|
+
- **Named config profiles with `extends:` inheritance** - a `profile:` block (or `--profile` flag) selects a bundled rule set instead of enumerating every rule by hand. Three built-ins ship with the binary: `gruff.minimal` (security and sensitive-data only), `gruff.recommended` (every pillar at its defaults - byte-identical to a zero-config scan), and `gruff.strict` (every pillar with tightened size, complexity, and secret thresholds). The inline form extends a built-in name or a relative profile file and overrides individual rules or ignored paths, with deterministic child-wins flattening (per-rule fields merge; `ignoredPaths` arrays replace). Precedence: `--profile` flag > config `profile:` > the `extends:` chain > the default `recommended`; a top-level `rules:` entry still overrides the profile. Unknown built-in/file, `extends:` cycles, and rule ids outside the catalogue all error at load time - file paths only, no remote URLs or shell. New `list-profiles` command plus `--profile <name-or-path>` on `analyse`/`report`/`summary`/`dashboard`. Config-only: no `gruff.analysis.*`/`gruff.baseline.*` schema change. The zero-dependency YAML parser and value-narrowing helpers moved from `src/config.ts` to a new `src/config-parse.ts` so the config module stays legible. (ADR-010; `src/profiles.ts`, `src/config.ts`, `src/config-parse.ts`, `src/cli-program.ts`, `src/rule-list.ts`, `src/types.ts`)
|
|
11
|
+
- **Region-scoped incremental analysis** - lets a coding agent run gruff-ts as a hook on only the code it changed, not the whole repo, so it resolves findings in its own diff before a human reviews and a clean change is never blocked by pre-existing findings elsewhere. `--changed-scope <symbol|hunk>` narrows findings to changed code: `symbol` reports findings whose enclosing declaration changed, `hunk` only those on changed lines. Driven by `--changed-ranges "<start>-<end>,..."`, `--since <ref>`, or `--diff` (including `git diff | gruff-ts analyse --diff -`). JSON keeps the normal `findings` array and adds `suppressedCount` when region filtering is active, so a PR check can gate on "did this change introduce findings?" without a baseline file. (`src/changed-regions.ts`, `src/analyser.ts`, `src/cli-program.ts`, `src/types.ts`)
|
|
12
|
+
- **Region-scoped analysis hardening** - diff-scoped runs now keep full project context for cross-file rules before filtering emitted findings, so central tests/import graphs remain visible while unchanged findings are still suppressed. Piped unified diffs track actual added target lines instead of hunk-header spans, deletion-only hunks no longer create target ranges, base-ref diffs no longer pull in unrelated untracked files, custom refs are passed after `--end-of-options`, file-wide findings stay visible when any hunk touches their file, and `export default class` bodies participate in symbol-scope matching. (`src/analyser.ts`, `src/changed-regions.ts`)
|
|
13
|
+
- **`paths.ignore` authoritative everywhere + `check-ignore` command** - config `paths.ignore` now excludes a path in every invocation shape, not just the directory walk: explicit file operands (`gruff-ts analyse src/generated.ts`) and diff/changed-region runs honour it too, so a coding-agent hook stops surfacing findings for deliberately-excluded files. `--include-ignored` opts into git/default ignores only and never overrides `paths.ignore`. The report's `paths` gains an additive `skipped: [{ path, source, pattern }]` array (`gruff.analysis.v2` unchanged; `ignoredPaths` kept as the back-compatible `string[]`). New `gruff-ts check-ignore [--format text|json] <paths...>` reports per path whether gruff would ignore it and by which source+pattern, sharing the exact ignore engine as `analyse` (no second matcher) and mirroring `git check-ignore` exit codes (0 = at least one ignored, 1 = none, 2 = error). (ADR-007, M27; `src/discovery.ts`, `src/check-ignore.ts`, `src/cli-program.ts`, `src/analyser.ts`, `src/types.ts`)
|
|
14
|
+
- **`check-ignore` semantics tightened** - explicit file checks no longer apply `.gitignore` rules that `analyse <file>` would bypass, while files under built-in ignored parent directories (for example `dist/generated.ts`) report the same default-ignore verdict that a directory scan would apply. (`src/discovery.ts`)
|
|
15
|
+
- **Sensitive-data: PHI + GCP service-account detection** - two new rules take the catalogue to 120: `sensitive-data.phi-pattern` flags PHI identifiers (Medicare Beneficiary Identifiers and labelled medical-record numbers) and `sensitive-data.gcp-service-account-key` flags GCP service-account key files (`"type": "service_account"` alongside a private key). Both route through the existing redaction contract, so no renderer (text/json/sarif/github/markdown/html) ever shows the raw value - only a redacted preview. Vendor secrets stay grouped under `sensitive-data.api-key-pattern` (no provider-specific rule split). (M26; `src/sensitive-data-rules.ts`, `src/rules.ts`)
|
|
16
|
+
- **Sensitive-data false-positive and profile fixes** - GCP service-account metadata now requires an actual `private_key` field or PEM private-key marker, not just `private_key_id`, before emitting the high-severity key-file finding. The strict profile's 24-character high-entropy threshold is now reachable because the detector enumerates candidates at the configured floor instead of hardcoding 32 characters first. (`src/sensitive-data-rules.ts`, `src/config.ts`, `src/profiles.ts`)
|
|
17
|
+
- **Dashboard secret redaction proof** - the live dashboard `/scan` HTML path now has a regression test proving sensitive-data findings render only redacted previews and do not include the raw synthetic credential URL or password fragment. No dashboard wire-format change. (`src/cli-surfaces.test.ts`)
|
|
18
|
+
- **Mission-first documentation + governance ADRs** - README, `docs/`, `.goat-flow/architecture.md`, and the `CLAUDE.md`/`AGENTS.md` headers now lead with gruff's purpose as a coding-agent hook: legible enough to verify, secure where the reviewer's eye slips, tested for real behaviour over low-signal ceremony. New `docs/philosophy.md` (the why) and `docs/agent-hook.md` (wiring it as a forcing function on agent output). ADR-005 records the mission; ADR-006 records that severity is ordering, not a gate (one severity + one value per rubric, no "tolerate N" gating). The npm description and HTML report masthead are reframed to match. (`README.md`, `docs/philosophy.md`, `docs/agent-hook.md`, `.goat-flow/decisions/ADR-005-optimise-for-reviewer-of-ai-generated-code.md`, `ADR-006-agents-fix-everything-severity-is-not-a-gate.md`)
|
|
19
|
+
- **Rubric calibration pass** - naming, test-quality, maintainability, and score/reporting rules now recognise stable reviewable-code conventions instead of forcing noisy rewrites: semantic digits in IDs, serialized/interface boolean names via `allowlists.acceptedBooleanNames`, comparator `(a, b)` parameters, fixture/invariant test sweeps, small cardinality assertions, documented empty test doubles, rationale-backed double casts, and prose-like comments that are not disabled code. Complexity and size score math now clusters overlapping root-cause findings once per function symbol while preserving each detailed finding and the `gruff.analysis.v2` field shape. (M06 / cross-port M14 policy, ADR-009; `src/class-rules.ts`, `src/naming-pushers.ts`, `src/test-block-rules.ts`, `src/blocks.ts`, `src/safety-rules.ts`, `src/findings-helpers.ts`, `src/scoring.ts`, `src/report-renderers.ts`)
|
|
20
|
+
- **Rule precision follow-ups** - DTO/interface fields and SCREAMING_SNAKE constants no longer hide same-surface local casing drift, semicolonless disabled calls are detected without reclassifying prose headings, conditional assertions inside type guards stay visible to `test-quality.conditional-logic`, and comments naming the changed-region CLI flags no longer trip `docs.stale-comment`. Synthetic test names are escaped before embedding in generated fixture source. (`src/class-rules.ts`, `src/findings-helpers.ts`, `src/test-block-rules.ts`, `src/comment-rules.ts`, `src/test-fixtures.ts`)
|
|
21
|
+
|
|
22
|
+
- **Security: cross-line source-to-sink flow (syntax-only AST)** - `security.ssrf-candidate`, `security.path-traversal-candidate`, `security.open-redirect-candidate`, and `security.dynamic-regexp` now also fire when external input (request fields, `process.argv`/`process.env`, `location.search`) is assigned to a local variable and reaches a network, filesystem, redirect, navigation, or regular-expression sink on a *later* line within the same function, via a bounded intra-function tracker over `ts.createSourceFile` (syntax-only; no type checker, program, or emit). One alias hop, assignment propagation, simple destructuring, reassignment clearing, and a per-scope statement cap keep it conservative; nested functions are pruned (intra-procedural), and an unparseable file degrades to the same-line scan. Same-line detection and all existing finding fingerprints are unchanged; flow findings carry `sourceKind`/`sinkKind`/`flowDepth` metadata with no raw user-controlled values. `typescript` is promoted from a dev dependency to a runtime dependency for this (syntax-only usage only). (ADR-012; `src/security-flow-rules.ts`, `src/analyser.ts`)
|
|
23
|
+
- **Security-flow false-positive fixes** - AST flow now skips callback bodies when inspecting sink arguments, ignores source-shaped string literals such as `"req.query.path"`, and reports the cross-line `location.href = taintedLocal` redirect assignment form that the same-line scanner already covers directly. (`src/security-flow-rules.ts`)
|
|
24
|
+
- **Security: unsafe deserialization + XXE candidates** - two AST-backed security rules expand the catalogue to 121 rules: `security.unsafe-deserialization` flags external input reaching `node-serialize` `unserialize`, unsafe `js-yaml` `load`, `vm` execution, `eval`, or `Function`; `security.xxe-candidate` flags external XML reaching `libxmljs`, `DOMParser`, or `fast-xml-parser` parser calls when local options enable entity expansion. Safe YAML schemas and XML parser calls with entity expansion disabled stay quiet, and metadata carries only source/sink classes plus bounded flow depth, never raw payloads. No schema, `Finding`, SARIF, dashboard wire-format, or fingerprint contract change. (`src/security-flow-rules.ts`, `src/rules.ts`)
|
|
25
|
+
- **Security: package `file:` dependency detection** - the existing `security.url-dependency` package-config rule now also flags `file:` dependency specs alongside remote URL, git, and hosting-shortcut specs. No new dependency rule IDs were added; existing lifecycle, remote install, URL dependency, and broad runtime-version coverage remains the supply-chain surface. (`src/project-config-rules.ts`)
|
|
26
|
+
|
|
3
27
|
## v0.2.0 - 2026-05-28
|
|
4
28
|
|
|
5
29
|
Cross-format Pillars table, per-command gating defaults, JSON schema bumps (`v1` → `v2`), exported-doc rule split, a rule-precision sweep, config schema-versioning, and a code-review sweep against PR #4 feedback. Cut as a pre-1.0 minor bump because the cumulative rule-emission changes (new exported-doc surface, tightened naming/test-quality exemptions, schemaVersion requirement) materially shift findings for downstream consumers.
|
package/README.md
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
# gruff-ts
|
|
2
2
|
|
|
3
|
-
`gruff-ts` is
|
|
3
|
+
`gruff-ts` governs AI-generated code. Wired in as a coding-agent hook, it forces the agent to produce changes a human who did not write them can actually sign off on: legible enough to verify by reading, secure where the human eye slips, and tested for real behaviour instead of padded with low-signal ceremony. Mechanically it is a dependency-light, opinionated static analyser for TypeScript and JavaScript - it scans source, tests, package metadata, and common config files, then emits reports for terminals, CI annotations, SARIF consumers, static HTML, and a local dashboard. It is heuristic static analysis; run it beside `tsc`, ESLint, tests, dependency scanners, and code review, not instead of them.
|
|
4
|
+
|
|
5
|
+
## Why gruff-ts Exists
|
|
6
|
+
|
|
7
|
+
The reviewer of AI-generated code is not its author. A coding agent holds the full context while it writes; the human who has to read, review, and trust the result does not. Conventional linters optimise for the author who already understands the code and just wants it tidy. gruff-ts optimises for that reviewer instead, which is the position every human signing off on an agent's output is in.
|
|
8
|
+
|
|
9
|
+
That goal breaks into three:
|
|
10
|
+
|
|
11
|
+
- **Verifiable.** A reviewer can read the change and confirm it does what was asked, rather than re-deriving what the agent was thinking. The complexity, size, naming, and documentation pillars push toward code whose intent is visible on its face.
|
|
12
|
+
- **Secure where the eye slips.** Human review reliably scans past a known set of unsafe patterns - disabled TLS verification, `eval` and dynamic `Function` construction, injection-shaped string building, committed secrets. The security and sensitive-data pillars catch those mechanically so the reviewer does not have to.
|
|
13
|
+
- **Honestly tested.** A suite should raise confidence, not just coverage. The test-quality pillar flags low-signal ceremony - mock-only, snapshot-only, assertion-free, and tautological tests - so an agent cannot satisfy a "write tests" instruction with padding.
|
|
14
|
+
|
|
15
|
+
Documentation rules carry extra weight here, which is why a doc comment is expected even on a private one-liner. Coding agents routinely produce code that superficially works while misunderstanding the requirement. Forcing the agent to state intent, usage, contract, and failure behaviour in prose gives a reviewer something to check the implementation against - a mismatch between the doc comment and the code is itself a signal that the change needs a deeper look.
|
|
16
|
+
|
|
17
|
+
Used as a hook on an agent's output, gruff-ts is a forcing function rather than advice: a finding is friction the agent must resolve before the change reaches a human, so what finally lands is already shaped for sign-off. See [Philosophy](docs/philosophy.md) for the longer form.
|
|
4
18
|
|
|
5
19
|
## Status At A Glance
|
|
6
20
|
|
|
7
21
|
| Field | Value |
|
|
8
22
|
| --- | --- |
|
|
9
|
-
| Release line | Published `0.
|
|
23
|
+
| Release line | Published `0.3.0` package line |
|
|
10
24
|
| Runtime | Node.js `22+` |
|
|
11
25
|
| Package | `@blundergoat/gruff-ts` |
|
|
12
26
|
| Binary | `gruff-ts` |
|
|
13
|
-
| Rule catalogue |
|
|
27
|
+
| Rule catalogue | 121 rules across 11 pillars |
|
|
14
28
|
| Primary config | `.gruff-ts.yaml`; `.gruff.json`, `.gruff.yaml`, and `.gruff.yml` are fallback files |
|
|
15
29
|
| Analysis schema | `gruff.analysis.v2` |
|
|
16
30
|
| Baseline schema | `gruff.baseline.v1` |
|
|
17
31
|
| Severity gate | `--fail-on` with `none`, `advisory`, `warning`, `error` |
|
|
18
32
|
| Dashboard | `127.0.0.1:8767` by default |
|
|
19
33
|
|
|
20
|
-
Scanned file types include TypeScript, JavaScript,
|
|
34
|
+
Scanned file types include TypeScript, JavaScript, JSON, YAML, TOML, INI, XML, and `.env*`.
|
|
21
35
|
|
|
22
36
|
## Requirements
|
|
23
37
|
|
|
@@ -78,6 +92,8 @@ Open `http://127.0.0.1:8767/` for the dashboard.
|
|
|
78
92
|
| `report [paths...]` | Render an HTML or JSON report to stdout or `--output`. |
|
|
79
93
|
| `init` | Write the default `.gruff-ts.yaml` to the current directory (`--force` to overwrite). |
|
|
80
94
|
| `list-rules` | Print rule metadata as text or JSON. |
|
|
95
|
+
| `list-profiles` | Print the built-in profiles (`gruff.minimal`, `gruff.recommended`, `gruff.strict`) with their rule-count summary, as text or JSON. |
|
|
96
|
+
| `check-ignore <paths...>` | Report whether each path is ignored (config, gitignore, or default) with the matching source and pattern; runs no analysis. |
|
|
81
97
|
| `dashboard` | Serve the local browser dashboard. |
|
|
82
98
|
| `completion [shell]` | Print a shell completion script for `bash`, `zsh`, or `fish`. |
|
|
83
99
|
| `list`, `help` | Show command lists and command-specific help. |
|
|
@@ -150,6 +166,9 @@ allowlists:
|
|
|
150
166
|
acceptedAbbreviations:
|
|
151
167
|
- api
|
|
152
168
|
- cli
|
|
169
|
+
acceptedBooleanNames:
|
|
170
|
+
- verbose
|
|
171
|
+
- enabled
|
|
153
172
|
secretPreviews: []
|
|
154
173
|
|
|
155
174
|
rules:
|
|
@@ -163,22 +182,61 @@ rules:
|
|
|
163
182
|
|
|
164
183
|
See [Configuration](docs/configuration.md) for the full config shape.
|
|
165
184
|
|
|
185
|
+
## Profiles
|
|
186
|
+
|
|
187
|
+
A `profile:` selects a named bundle of rules instead of enumerating every rule by hand. Three profiles ship with the binary:
|
|
188
|
+
|
|
189
|
+
| Profile | Intent |
|
|
190
|
+
| --- | --- |
|
|
191
|
+
| `gruff.minimal` | Security and sensitive-data rules only - the smallest sanity gate for incremental adoption. |
|
|
192
|
+
| `gruff.recommended` | Every pillar at its default threshold and severity - identical to gruff's zero-config behaviour. |
|
|
193
|
+
| `gruff.strict` | Every pillar enabled with tightened size, complexity, and secret thresholds for high-bar repositories. |
|
|
194
|
+
|
|
195
|
+
`gruff-ts list-profiles` prints them with their enabled-rule counts. Select one in config or on the CLI:
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
# Shorthand: the whole profile in one line.
|
|
199
|
+
profile: recommended
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
```yaml
|
|
203
|
+
# Compose: extend a built-in, then override a few rules or add ignored paths.
|
|
204
|
+
profile:
|
|
205
|
+
extends: gruff.recommended # a built-in name OR a relative path like ./team-profile.yaml
|
|
206
|
+
rules:
|
|
207
|
+
complexity.cyclomatic:
|
|
208
|
+
threshold: 12
|
|
209
|
+
docs.missing-public-doc:
|
|
210
|
+
enabled: false
|
|
211
|
+
ignoredPaths:
|
|
212
|
+
- "examples/**"
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
`--profile <name-or-path>` applies a profile for one run (on `analyse`, `report`, `summary`, and `dashboard`) and overrides a config-file `profile:`. The value is a built-in name (the bare `minimal` / `recommended` / `strict` short forms are accepted too) or a path to a `.yaml`/`.yml`/`.json` profile file.
|
|
216
|
+
|
|
217
|
+
Semantics:
|
|
218
|
+
|
|
219
|
+
- **Precedence (highest first):** `--profile` flag, config `profile:` block, the `extends:` base chain, the built-in default `gruff.recommended`. A top-level `rules:` entry still overrides the profile for that rule.
|
|
220
|
+
- **`extends:`** accepts a built-in name or a relative file path - never a remote URL, never shell. A shared profile file's top level is itself a profile spec (`extends` / `rules` / `ignoredPaths`).
|
|
221
|
+
- **Last-wins, deterministic:** a child profile's per-rule fields override the parent's same-rule fields, and a child `ignoredPaths` array replaces (does not concatenate) the parent's.
|
|
222
|
+
- **Validated at load time:** an unknown built-in name resolved as a missing file, a missing `extends:` file, an `extends:` cycle, and a rule id outside the catalogue all fail with a clear error before any scan runs.
|
|
223
|
+
|
|
166
224
|
## Rules And Pillars
|
|
167
225
|
|
|
168
|
-
The
|
|
226
|
+
The current catalogue contains 121 rules:
|
|
169
227
|
|
|
170
228
|
| Pillar | Rules |
|
|
171
229
|
| --- | ---: |
|
|
172
|
-
| `complexity` |
|
|
230
|
+
| `complexity` | 2 |
|
|
173
231
|
| `dead-code` | 1 |
|
|
174
|
-
| `design` |
|
|
175
|
-
| `documentation` |
|
|
232
|
+
| `design` | 5 |
|
|
233
|
+
| `documentation` | 18 |
|
|
176
234
|
| `maintainability` | 14 |
|
|
177
235
|
| `modernisation` | 14 |
|
|
178
236
|
| `naming` | 10 |
|
|
179
|
-
| `security` |
|
|
180
|
-
| `sensitive-data` |
|
|
181
|
-
| `size` |
|
|
237
|
+
| `security` | 29 |
|
|
238
|
+
| `sensitive-data` | 10 |
|
|
239
|
+
| `size` | 3 |
|
|
182
240
|
| `test-quality` | 15 |
|
|
183
241
|
|
|
184
242
|
Use `npx gruff-ts list-rules --format=json` for exact rule IDs, severities, confidence levels, remediation text, thresholds, and options.
|
|
@@ -202,6 +260,16 @@ npx gruff-ts analyse . --diff=staged --format=json --fail-on=none
|
|
|
202
260
|
|
|
203
261
|
`--diff` accepts `working-tree`, `staged`, `unstaged`, or a base ref. `report` renders raw inspection output and does not accept `--baseline`; use `analyse` when baseline suppression matters.
|
|
204
262
|
|
|
263
|
+
Changed-region scans keep only findings attributable to the changed hunk or its enclosing symbol:
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
npx gruff-ts analyse --format=json --changed-ranges "3-3,8-10" src/foo.ts
|
|
267
|
+
npx gruff-ts analyse --format=json --since HEAD src/foo.ts
|
|
268
|
+
git diff | npx gruff-ts analyse --format=json --diff -
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
JSON output keeps the normal `findings` array and adds `suppressedCount` when changed-region filtering is active.
|
|
272
|
+
|
|
205
273
|
## Dashboard
|
|
206
274
|
|
|
207
275
|
```bash
|
|
@@ -218,7 +286,7 @@ Default scans are local source inspections. `gruff-ts` parses supported source,
|
|
|
218
286
|
|
|
219
287
|
## Stability Contract
|
|
220
288
|
|
|
221
|
-
The `0.
|
|
289
|
+
The `0.3.x` line treats rule IDs, finding fingerprints, baseline identity, `gruff.analysis.v2`, `gruff.baseline.v1`, `gruff.hotspot.v1`, SARIF rendering, and CLI exit semantics as compatibility-sensitive. Breaking changes should be tagged as a future minor release and recorded in [`CHANGELOG.md`](CHANGELOG.md).
|
|
222
290
|
|
|
223
291
|
## How It Compares
|
|
224
292
|
|
package/docs/README.md
CHANGED
|
@@ -4,6 +4,8 @@ Use these docs with the top-level README for the stable user-facing surface.
|
|
|
4
4
|
|
|
5
5
|
## Core Docs
|
|
6
6
|
|
|
7
|
+
- [Philosophy](philosophy.md) - what gruff-ts optimises for and why it governs AI-generated code for human sign-off.
|
|
8
|
+
- [Coding-agent hook](agent-hook.md) - wiring gruff-ts as a forcing function on agent output: changed-region scans, gate levels, and CI.
|
|
7
9
|
- [Configuration](configuration.md) - config discovery, schema, allowlists, and rule overrides.
|
|
8
10
|
- [Rules](rules.md) - rule IDs, severities, thresholds, and remediation guidance.
|
|
9
11
|
- [Output Formats](output-formats.md) - text, JSON, HTML, Markdown, GitHub annotations, hotspot, and SARIF.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Using gruff-ts As A Coding-Agent Hook
|
|
2
|
+
|
|
3
|
+
gruff-ts is built to govern AI-generated code (see [Philosophy](philosophy.md) for the why). This page is the practical how: wiring it in so it acts as a forcing function on an agent's output, before a human is asked to review.
|
|
4
|
+
|
|
5
|
+
## The model
|
|
6
|
+
|
|
7
|
+
A coding agent will rewrite code until the checks pass. gruff-ts turns that into leverage: run it on the agent's change and gate on the result, so the agent has to resolve findings - add the missing doc comment, cut the unverifiable branching, drop the unsafe call, replace the mock-only test - before the change reaches you. What lands is already shaped for sign-off.
|
|
8
|
+
|
|
9
|
+
The gate is the exit code:
|
|
10
|
+
|
|
11
|
+
- `0` - no finding met the `--fail-on` level; the change passes.
|
|
12
|
+
- `1` - at least one finding met `--fail-on`; the agent must fix and re-run.
|
|
13
|
+
- `2` - fatal (bad input, parse or config error); stop and surface it.
|
|
14
|
+
|
|
15
|
+
## Scan the change, not the repo
|
|
16
|
+
|
|
17
|
+
> **Goal:** govern only the code the agent changed, not the whole repo - so the agent resolves findings in its own diff and a clean change is never blocked by pre-existing findings elsewhere.
|
|
18
|
+
|
|
19
|
+
Gate the agent on what it actually touched, so a clean diff is not blocked by pre-existing findings elsewhere:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Uncommitted working-tree changes (typical agent loop)
|
|
23
|
+
npx gruff-ts analyse . --diff=working-tree --fail-on=warning
|
|
24
|
+
|
|
25
|
+
# Staged changes (pre-commit)
|
|
26
|
+
npx gruff-ts analyse . --diff=staged --fail-on=warning
|
|
27
|
+
|
|
28
|
+
# Everything changed since a ref (pre-push or PR)
|
|
29
|
+
npx gruff-ts analyse . --since origin/main --fail-on=warning
|
|
30
|
+
|
|
31
|
+
# Exact hunks, when the agent already knows the line ranges
|
|
32
|
+
npx gruff-ts analyse --changed-ranges "12-40,88-90" src/foo.ts --fail-on=warning
|
|
33
|
+
|
|
34
|
+
# Piped diff
|
|
35
|
+
git diff | npx gruff-ts analyse --diff - --fail-on=warning
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Changed-region scans keep only findings attributable to the changed hunk or its enclosing symbol, so the agent fixes its own work instead of inheriting the whole backlog.
|
|
39
|
+
|
|
40
|
+
## Respect the project's ignore policy
|
|
41
|
+
|
|
42
|
+
A hook passes the agent's changed files directly, so the project's `paths.ignore` must hold for those explicit paths too - otherwise the agent burns loops "fixing" generated or vendored code the project deliberately excludes. Config `paths.ignore` is authoritative in every invocation (explicit operand, diff, changed-region): a matching path produces no findings and is listed in the report's `paths.skipped` with its `source` and `pattern`. `--include-ignored` opts into git/default ignores only and never overrides `paths.ignore`.
|
|
43
|
+
|
|
44
|
+
To pre-filter a changed-file list before scanning, ask gruff which paths it would skip - it shares the same engine as `analyse` and runs no analysis:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# Which of the agent's changed files would gruff skip?
|
|
48
|
+
gruff-ts check-ignore $CHANGED_FILES --format json
|
|
49
|
+
# exit 0 = at least one ignored, 1 = none, 2 = config error
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Picking the gate level
|
|
53
|
+
|
|
54
|
+
`--fail-on` sets the bar the agent must clear. Built-in defaults are `advisory` for `analyse` and `summary`, `none` for `report`; raise or lower per surface:
|
|
55
|
+
|
|
56
|
+
| Level | Use it as the agent gate when |
|
|
57
|
+
| --- | --- |
|
|
58
|
+
| `error` | You only want to block the highest-severity issues (committed secrets, `eval`, disabled TLS). Minimal friction. |
|
|
59
|
+
| `warning` | Recommended default. Blocks the security and correctness tier plus the verifiability signals (complexity, missing exported-API docs, weak tests) while leaving advisories as nudges. |
|
|
60
|
+
| `advisory` | Strictest. Every finding is friction the agent must clear. Best when you want maximum legibility pressure and can tolerate more agent rework. |
|
|
61
|
+
|
|
62
|
+
Per-command levels can be pinned in `.gruff-ts.yaml` via the `minimumSeverity:` block (see [Configuration](configuration.md)); precedence is CLI flag > config > built-in default.
|
|
63
|
+
|
|
64
|
+
## Fix, do not suppress
|
|
65
|
+
|
|
66
|
+
Baselines exist for legacy adoption, not agent governance. Suppressing an agent's findings defeats the purpose: the goal is code a human can verify, and a baseline hides exactly the things they would check. Gate the agent on its diff (above) rather than baselining its output; if you must scope a run, scope it by changed region, not by suppression.
|
|
67
|
+
|
|
68
|
+
## In CI
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# Annotate the PR and fail the job on warning-or-higher findings
|
|
72
|
+
npx gruff-ts analyse . --since origin/main --format=github --fail-on=warning
|
|
73
|
+
|
|
74
|
+
# Security-only gate that ignores any adoption baseline
|
|
75
|
+
npx gruff-ts analyse . --no-baseline --fail-on=error
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Why the doc-comment pressure is deliberate
|
|
79
|
+
|
|
80
|
+
The documentation pillar is strict on purpose - a doc comment is expected even on a private one-liner. An agent that states intent, usage, contract, and failure behaviour in prose gives you a second, independent description to check the code against, and a mismatch between the comment and the code is itself a signal the change needs a closer look. Treat documentation findings as part of the verifiability gate, not as optional polish.
|
package/docs/ci-integration.md
CHANGED
|
@@ -54,6 +54,22 @@ TypeScript supports working-tree, staged, unstaged, and base-ref diff scans:
|
|
|
54
54
|
./bin/gruff-ts analyse src --diff=origin/main --format=json --fail-on=none
|
|
55
55
|
```
|
|
56
56
|
|
|
57
|
+
## Ignored Paths
|
|
58
|
+
|
|
59
|
+
Config `paths.ignore` is authoritative in every invocation mode - a matching
|
|
60
|
+
path is excluded and produces no findings whether it is reached by a directory
|
|
61
|
+
walk, passed explicitly, or touched by a diff. Each excluded path is reported in
|
|
62
|
+
`paths.skipped` with its `source` and `pattern`. `--include-ignored` affects
|
|
63
|
+
git-ignored and default-ignored paths only; it never overrides `paths.ignore`.
|
|
64
|
+
|
|
65
|
+
`check-ignore` answers "would gruff skip this path?" without running a scan,
|
|
66
|
+
mirroring `git check-ignore` exit codes (0 = at least one ignored, 1 = none,
|
|
67
|
+
2 = error) - useful in a pre-scan hook step to drop out-of-scope changed files:
|
|
68
|
+
|
|
69
|
+
```sh
|
|
70
|
+
./bin/gruff-ts check-ignore src/generated/client.ts src/app.ts --format json
|
|
71
|
+
```
|
|
72
|
+
|
|
57
73
|
## Check
|
|
58
74
|
|
|
59
75
|
Run the local TypeScript gate before release:
|
package/docs/configuration.md
CHANGED
|
@@ -76,7 +76,8 @@ allowlists:
|
|
|
76
76
|
- cli
|
|
77
77
|
secretPreviews: []
|
|
78
78
|
bannedGenericNames: [process, handle, doit, run, execute, manage]
|
|
79
|
-
|
|
79
|
+
acceptedBooleanNames: [all, apply, check, dev, enabled, force, fresh, harness, json, ok, verbose, yes]
|
|
80
|
+
booleanPrefixes: [is, has, can, should, does, did, was, will, may, in, scan, supports, requires, allow, check, enable, exclude, include, omit, skip, with, without]
|
|
80
81
|
hungarianPrefixes: [str, obj, arr, bool, int, num]
|
|
81
82
|
placeholderNames: [foo, bar, baz, tmp, temp, thing, stuff, data, value, item]
|
|
82
83
|
negativeBooleanAllowed: [nostore, nofollow, noreferrer, noscript, noindex]
|
|
@@ -116,7 +117,21 @@ generated, node_modules, target, tmp, vendor
|
|
|
116
117
|
|
|
117
118
|
Use `--include-ignored` when you intentionally want to scan default ignored
|
|
118
119
|
directories and Git-ignored paths. Configured `paths.ignore` entries still
|
|
119
|
-
apply.
|
|
120
|
+
apply - `--include-ignored` never overrides them.
|
|
121
|
+
|
|
122
|
+
`paths.ignore` is authoritative in every invocation mode (ADR-007): a matching
|
|
123
|
+
path is excluded and produces no findings whether it is reached by a directory
|
|
124
|
+
walk, passed as an explicit file operand (`gruff-ts analyse src/generated-client.ts`),
|
|
125
|
+
or touched by a diff/changed-region run. Excluded paths appear in the report's
|
|
126
|
+
`paths.skipped` array with their `source` (`config` / `gitignore` / `default`) and
|
|
127
|
+
the matching `pattern`. Query a path without scanning via `check-ignore`, which
|
|
128
|
+
shares the same engine and mirrors `git check-ignore` exit codes (0 = at least
|
|
129
|
+
one ignored, 1 = none, 2 = error):
|
|
130
|
+
|
|
131
|
+
```sh
|
|
132
|
+
gruff-ts check-ignore src/generated-client.ts --format json
|
|
133
|
+
# [ { "path": "src/generated-client.ts", "ignored": true, "source": "config", "pattern": "src/generated-client.ts" } ]
|
|
134
|
+
```
|
|
120
135
|
|
|
121
136
|
## Allowlists
|
|
122
137
|
|
|
@@ -149,6 +164,7 @@ fingerprints:
|
|
|
149
164
|
| Key | Used by | Default behavior |
|
|
150
165
|
| --- | --- | --- |
|
|
151
166
|
| `acceptedAbbreviations` | `naming.short-variable` | Adds short names that should not be flagged. |
|
|
167
|
+
| `acceptedBooleanNames` | `naming.boolean-prefix` | Replaces exact public/CLI/DTO boolean names such as `verbose`, `enabled`, `ok`, and `force`. |
|
|
152
168
|
| `bannedGenericNames` | `naming.generic-function` | Replaces the built-in generic function-name denylist. |
|
|
153
169
|
| `booleanPrefixes` | `naming.boolean-prefix` | Replaces the accepted boolean-name prefixes such as `is`, `has`, `should`, `may`, `supports`, and `requires`. |
|
|
154
170
|
| `hungarianPrefixes` | `naming.hungarian-notation` | Replaces type-style prefixes to flag. |
|
|
@@ -217,6 +233,9 @@ allowlists:
|
|
|
217
233
|
- cli
|
|
218
234
|
- env
|
|
219
235
|
- id
|
|
236
|
+
acceptedBooleanNames:
|
|
237
|
+
- verbose
|
|
238
|
+
- enabled
|
|
220
239
|
secretPreviews: []
|
|
221
240
|
|
|
222
241
|
rules:
|
package/docs/output-formats.md
CHANGED
|
@@ -20,6 +20,16 @@ Use `json` for automation. JSON reports use `gruff.analysis.v2`.
|
|
|
20
20
|
./bin/gruff-ts analyse src --format=json --fail-on=none > gruff-ts.json
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
+
`paths.skipped` (added in 0.3.0) lists every excluded path with its ignore
|
|
24
|
+
`source` (`config` / `gitignore` / `default`) and the matching `pattern`;
|
|
25
|
+
`paths.ignoredPaths` remains as the back-compatible `string[]` of the same paths.
|
|
26
|
+
The field is additive, so existing `gruff.analysis.v2` consumers are unaffected.
|
|
27
|
+
|
|
28
|
+
Score math clusters correlated `complexity.cognitive`,
|
|
29
|
+
`complexity.cyclomatic`, and `size.function-length` findings once per function
|
|
30
|
+
symbol. The detailed `findings` array still lists each rule finding; only pillar
|
|
31
|
+
penalties and offender scores are de-duplicated.
|
|
32
|
+
|
|
23
33
|
## HTML
|
|
24
34
|
|
|
25
35
|
Use `html` for archived human review or dashboard scan output:
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Philosophy
|
|
2
|
+
|
|
3
|
+
gruff-ts governs AI-generated code. Every rule, threshold, and report exists to serve one goal: a human who did not write the code can read, review, and trust it.
|
|
4
|
+
|
|
5
|
+
## The reviewer is not the author
|
|
6
|
+
|
|
7
|
+
A coding agent holds the full context while it writes. The person who has to sign off on the change does not. Conventional linters optimise for the author - they assume someone who already understands the code and just wants it tidy. gruff-ts optimises for the reviewer of code they did not write, which is the position every human reviewing an agent's output is in.
|
|
8
|
+
|
|
9
|
+
Used as a hook on an agent's output, gruff-ts is a forcing function, not advice. A finding is friction the agent must resolve before the change reaches a human, so what finally lands is already shaped for sign-off. Because the agent will change code to clear a finding, the direction each rule pushes matters as much as the threshold it fires at: a rule should never push the agent toward code that is harder to verify or less safe.
|
|
10
|
+
|
|
11
|
+
## Three goals
|
|
12
|
+
|
|
13
|
+
- **Verifiable.** The change can be checked by reading, not by re-deriving what the agent was thinking. The complexity, size, naming, and documentation pillars push toward code whose intent is visible on its face.
|
|
14
|
+
- **Secure where the eye slips.** Human review reliably misses a known set of unsafe patterns - disabled TLS verification, `eval` and dynamic `Function` construction, injection-shaped string building, committed secrets. The security and sensitive-data pillars catch those mechanically so the reviewer does not have to.
|
|
15
|
+
- **Honestly tested.** A test suite should raise confidence, not just coverage. The test-quality pillar flags low-signal ceremony - mock-only, snapshot-only, assertion-free, and tautological tests - so an agent cannot satisfy a "write tests" instruction with padding.
|
|
16
|
+
|
|
17
|
+
## Why documentation is mandatory, even on a private one-liner
|
|
18
|
+
|
|
19
|
+
Coding agents routinely produce code that superficially works while misunderstanding the requirement. The implementation can be plausible and still solve the wrong problem, and that failure is invisible to a reviewer reading only the code.
|
|
20
|
+
|
|
21
|
+
Forcing the agent to state intent, usage, contract, and failure behaviour in prose gives the reviewer something to check the implementation against. The doc comment is a second, independent statement of what the code is meant to do, and a mismatch between that prose and the code is itself a signal that the change needs a deeper look. That is worth the friction even on a one-line private helper, because the cost of a confidently-wrong agent change is paid by the human who trusted it.
|
package/docs/releasing.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Releasing
|
|
2
2
|
|
|
3
|
-
This checklist prepares public `@blundergoat/gruff-ts@0.
|
|
4
|
-
Current release line: `0.
|
|
3
|
+
This checklist prepares public `@blundergoat/gruff-ts@0.3.x` patch releases.
|
|
4
|
+
Current release line: `0.3.0`.
|
|
5
5
|
|
|
6
6
|
## Bump The Version
|
|
7
7
|
|
|
@@ -14,7 +14,7 @@ release version changes.
|
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
16
|
scripts/bump-version.sh --check
|
|
17
|
-
scripts/bump-version.sh 0.1
|
|
17
|
+
scripts/bump-version.sh 0.3.1
|
|
18
18
|
scripts/bump-version.sh --check
|
|
19
19
|
```
|
|
20
20
|
|
|
@@ -27,7 +27,7 @@ update `CHANGELOG.md` and run `npm run check`.
|
|
|
27
27
|
- [ ] `CHANGELOG.md` has an entry for the new version with today's date.
|
|
28
28
|
- [ ] `README.md`, `CONTRIBUTING.md`, `SECURITY.md`, and docs under `docs/`
|
|
29
29
|
reflect any user-visible changes.
|
|
30
|
-
- [ ] `.goat-flow/tasks/0.
|
|
30
|
+
- [ ] `.goat-flow/tasks/0.3.0/` has no unresolved release blockers beyond
|
|
31
31
|
explicitly accepted `human-verification-pending` milestones.
|
|
32
32
|
- [ ] `LICENSE` is present and `package.json` `license` field matches.
|
|
33
33
|
- [ ] `npm run check` passes.
|
|
@@ -102,5 +102,5 @@ prompts before publishing.
|
|
|
102
102
|
- [ ] Run `gruff-ts summary . --fail-on=none`.
|
|
103
103
|
- [ ] Run `gruff-ts list-rules`.
|
|
104
104
|
- [ ] Verify `README.md` install instructions from a clean checkout.
|
|
105
|
-
- [ ] Tag the release in git (`git tag v0.
|
|
105
|
+
- [ ] Tag the release in git (`git tag v0.3.0 && git push --tags`) and create
|
|
106
106
|
or update public release notes from `CHANGELOG.md`.
|
package/docs/rules.md
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
# Rules
|
|
2
2
|
|
|
3
|
-
`gruff-ts` exposes
|
|
3
|
+
`gruff-ts` exposes 121 rules across 11 pillars. This list is generated from the
|
|
4
4
|
public rule catalogue used by `gruff-ts list-rules`; severity, confidence,
|
|
5
5
|
thresholds, and option names are the defaults before project config overrides.
|
|
6
6
|
|
|
7
|
+
The pillars are organised around one goal: making AI-generated code something a
|
|
8
|
+
human who did not write it can verify by reading, trust as secure, and rely on as
|
|
9
|
+
honestly tested rather than padded with low-signal ceremony. Complexity, size,
|
|
10
|
+
naming, and documentation serve verifiability; security and sensitive-data serve
|
|
11
|
+
safety where review is weakest; test-quality guards against coverage theatre. See
|
|
12
|
+
[Philosophy](philosophy.md) for the intent behind the catalogue, including why a
|
|
13
|
+
doc comment is expected even on a private one-liner.
|
|
14
|
+
|
|
7
15
|
Use the CLI when you need machine-readable metadata:
|
|
8
16
|
|
|
9
17
|
```bash
|
|
@@ -12,23 +20,22 @@ gruff-ts list-rules --format=json
|
|
|
12
20
|
|
|
13
21
|
## Pillar Counts
|
|
14
22
|
|
|
15
|
-
- complexity:
|
|
23
|
+
- complexity: 2
|
|
16
24
|
- dead-code: 1
|
|
17
|
-
- design:
|
|
18
|
-
- documentation:
|
|
25
|
+
- design: 5
|
|
26
|
+
- documentation: 18
|
|
19
27
|
- maintainability: 14
|
|
20
28
|
- modernisation: 14
|
|
21
29
|
- naming: 10
|
|
22
|
-
- security:
|
|
23
|
-
- sensitive-data:
|
|
24
|
-
- size:
|
|
30
|
+
- security: 29
|
|
31
|
+
- sensitive-data: 10
|
|
32
|
+
- size: 3
|
|
25
33
|
- test-quality: 15
|
|
26
34
|
|
|
27
35
|
## Complexity
|
|
28
36
|
|
|
29
37
|
- `complexity.cognitive` (warning; high confidence; threshold 15): Flags functions with high combined branch and nesting complexity.
|
|
30
38
|
- `complexity.cyclomatic` (warning; high confidence; threshold 15): Flags functions with many independent branch paths.
|
|
31
|
-
- `complexity.npath` (warning; medium confidence; threshold 200): Flags functions with high approximate NPath complexity.
|
|
32
39
|
|
|
33
40
|
## Dead Code
|
|
34
41
|
|
|
@@ -38,7 +45,6 @@ gruff-ts list-rules --format=json
|
|
|
38
45
|
|
|
39
46
|
- `design.circular-import` (warning; medium confidence): Flags simple relative import cycles inside the discovered source set.
|
|
40
47
|
- `design.deep-relative-import` (advisory; medium confidence; threshold 2): Flags relative imports that climb too many parent directories.
|
|
41
|
-
- `design.god-function` (warning; high confidence): Flags functions that are both long and complex.
|
|
42
48
|
- `design.large-module-concentration` (advisory; medium confidence; threshold 55; options: minFiles, minLines): Flags a production module that dominates project source lines.
|
|
43
49
|
- `design.package-bin-missing` (warning; high confidence): Flags package bin entries that point at missing files.
|
|
44
50
|
- `design.package-bin-not-executable` (warning; high confidence): Flags package bin targets that are not executable.
|
|
@@ -83,7 +89,7 @@ gruff-ts list-rules --format=json
|
|
|
83
89
|
## Naming
|
|
84
90
|
|
|
85
91
|
- `naming.acronym-case` (advisory; medium confidence): Flags mixed casings of a known acronym in one file.
|
|
86
|
-
- `naming.boolean-prefix` (advisory; medium confidence): Flags boolean names without intent-revealing prefixes on declarations, function parameters (typed `: boolean` or with `= true|false` default), and interface/type-literal fields.
|
|
92
|
+
- `naming.boolean-prefix` (advisory; medium confidence; allowlists: booleanPrefixes, acceptedBooleanNames): Flags boolean names without intent-revealing prefixes on declarations, function parameters (typed `: boolean` or with `= true|false` default), and interface/type-literal fields.
|
|
87
93
|
- `naming.class-file-mismatch` (advisory; medium confidence): Flags exported classes whose name differs from the file name.
|
|
88
94
|
- `naming.generic-function` (advisory; high confidence): Flags generic function names that hide intent.
|
|
89
95
|
- `naming.generic-parameter` (advisory; medium confidence; options: minCyclomatic, minLineCount, minParameters): Flags placeholder parameter names in multi-parameter, long, exported, or complex functions.
|
|
@@ -120,18 +126,22 @@ gruff-ts list-rules --format=json
|
|
|
120
126
|
- `security.ssrf-candidate` (warning; medium confidence): Flags external input sent to network request sinks.
|
|
121
127
|
- `security.string-timer` (warning; high confidence): Flags string callbacks passed to timers.
|
|
122
128
|
- `security.throw-non-error` (warning; medium confidence): Flags thrown non-Error values.
|
|
123
|
-
- `security.
|
|
129
|
+
- `security.unsafe-deserialization` (warning; medium confidence): Flags external input reaching unsafe deserialization or dynamic code-loading sinks.
|
|
130
|
+
- `security.url-dependency` (warning; medium confidence): Flags dependencies installed from URL, git, or local file specs.
|
|
124
131
|
- `security.weak-crypto` (warning; high confidence): Flags weak crypto primitives such as md5, sha1, or createCipher.
|
|
132
|
+
- `security.xxe-candidate` (warning; medium confidence): Flags external XML reaching parsers configured to expand entities.
|
|
125
133
|
|
|
126
134
|
## Sensitive Data
|
|
127
135
|
|
|
128
|
-
- `sensitive-data.api-key-pattern` (error; high confidence): Flags vendor API key patterns.
|
|
136
|
+
- `sensitive-data.api-key-pattern` (error; high confidence): Flags vendor API key patterns including GitHub, GitLab, npm, Google API, Slack, Discord, and Stripe/OpenAI-style keys.
|
|
129
137
|
- `sensitive-data.aws-access-key` (error; high confidence): Flags AWS access key looking values.
|
|
130
|
-
- `sensitive-data.database-url-password` (error; high confidence): Flags database URLs that include passwords.
|
|
138
|
+
- `sensitive-data.database-url-password` (error; high confidence): Flags database and HTTP(S) URLs that include passwords or embedded credentials.
|
|
139
|
+
- `sensitive-data.gcp-service-account-key` (error; high confidence): Flags GCP service-account key files (type service_account alongside a private key).
|
|
131
140
|
- `sensitive-data.hardcoded-env-value` (error; medium confidence; threshold 16): Flags environment-style secret values committed in text.
|
|
132
141
|
- `sensitive-data.high-entropy-string` (error; medium confidence; threshold 32): Flags high-entropy string literals that may be secrets.
|
|
133
142
|
- `sensitive-data.jwt-token` (error; high confidence): Flags JWT-looking token literals.
|
|
134
|
-
- `sensitive-data.
|
|
143
|
+
- `sensitive-data.phi-pattern` (error; high confidence): Flags PHI identifiers such as Medicare (MBI) and medical record numbers.
|
|
144
|
+
- `sensitive-data.pii-pattern` (error; high confidence): Flags PII-like identifier patterns including SSN-shaped values and Luhn-valid payment cards.
|
|
135
145
|
- `sensitive-data.private-key` (error; high confidence): Flags private key block markers.
|
|
136
146
|
|
|
137
147
|
## Size
|
|
@@ -139,7 +149,6 @@ gruff-ts list-rules --format=json
|
|
|
139
149
|
- `size.file-length` (warning; high confidence; threshold 750): Flags files longer than the configured threshold.
|
|
140
150
|
- `size.function-length` (warning; high confidence; threshold 200): Flags functions longer than the configured threshold.
|
|
141
151
|
- `size.parameter-count` (warning; high confidence; threshold 7): Flags functions with too many parameters.
|
|
142
|
-
- `size.stylesheet-length` (warning; high confidence; threshold 1500): Flags stylesheets longer than the configured threshold.
|
|
143
152
|
|
|
144
153
|
## Test Quality
|
|
145
154
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blundergoat/gruff-ts",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Governs AI-generated code so a human can verify it: a TypeScript/JavaScript static analyzer - 119 rules across 11 quality pillars, SARIF output, baselines, and a local dashboard.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Matthew Hansen (https://www.blundergoat.com/about)",
|
|
7
7
|
"homepage": "https://github.com/blundergoat/gruff-ts#readme",
|
|
@@ -46,11 +46,11 @@
|
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"commander": "^14.0.2",
|
|
49
|
-
"tsx": "^4.21.0"
|
|
49
|
+
"tsx": "^4.21.0",
|
|
50
|
+
"typescript": "^5.9.3"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
53
|
"@blundergoat/goat-flow": "^1.6.4",
|
|
53
|
-
"@types/node": "^25.0.0"
|
|
54
|
-
"typescript": "^5.9.3"
|
|
54
|
+
"@types/node": "^25.0.0"
|
|
55
55
|
}
|
|
56
56
|
}
|
package/scripts/bump-version.sh
CHANGED
|
@@ -12,7 +12,7 @@ Usage:
|
|
|
12
12
|
scripts/bump-version.sh --check
|
|
13
13
|
|
|
14
14
|
Arguments:
|
|
15
|
-
<new-version> Target semver, e.g. 0.1.1, 0.2.0,
|
|
15
|
+
<new-version> Target semver, e.g. 0.1.1, 0.2.0, 0.3.0-rc.1.
|
|
16
16
|
|
|
17
17
|
Options:
|
|
18
18
|
--check Verify package.json, package-lock.json, src/constants.ts, and CHANGELOG.md
|