@blundergoat/gruff-ts 0.1.1 → 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.
Files changed (52) hide show
  1. package/CHANGELOG.md +55 -19
  2. package/README.md +103 -35
  3. package/docs/README.md +2 -0
  4. package/docs/agent-hook.md +80 -0
  5. package/docs/ci-integration.md +16 -0
  6. package/docs/configuration.md +60 -3
  7. package/docs/dashboard.md +7 -0
  8. package/docs/output-formats.md +11 -1
  9. package/docs/philosophy.md +21 -0
  10. package/docs/releasing.md +12 -11
  11. package/docs/reports-and-ci.md +5 -2
  12. package/docs/rules.md +24 -15
  13. package/package.json +5 -5
  14. package/scripts/bump-version.sh +20 -4
  15. package/scripts/preflight-checks.sh +4 -41
  16. package/src/analyser.ts +47 -34
  17. package/src/blocks.ts +82 -75
  18. package/src/changed-regions.ts +390 -0
  19. package/src/check-ignore.ts +49 -0
  20. package/src/class-rules.ts +80 -33
  21. package/src/cli-program.ts +209 -51
  22. package/src/comment-rules.ts +4 -0
  23. package/src/config-load-error.ts +18 -0
  24. package/src/config-parse.ts +458 -0
  25. package/src/config-preservation.ts +64 -0
  26. package/src/config.ts +311 -428
  27. package/src/constants.ts +10 -2
  28. package/src/context-doc-rules.ts +2 -4
  29. package/src/dashboard.ts +8 -5
  30. package/src/dead-code-rules.ts +60 -14
  31. package/src/discovery.ts +88 -32
  32. package/src/doc-rules.ts +3 -3
  33. package/src/findings-helpers.ts +58 -5
  34. package/src/fixtures/rule-catalogue-security-doctrine.ts +28 -0
  35. package/src/init-config.ts +94 -31
  36. package/src/line-rules.ts +58 -4
  37. package/src/naming-pushers.ts +42 -7
  38. package/src/pillar-summary.ts +129 -0
  39. package/src/profiles.ts +232 -0
  40. package/src/project-config-rules.ts +5 -5
  41. package/src/project-rules.ts +2 -1
  42. package/src/report-html.ts +404 -0
  43. package/src/report-renderers.ts +210 -397
  44. package/src/rule-list.ts +85 -1
  45. package/src/rules.ts +28 -27
  46. package/src/safety-rules.ts +22 -7
  47. package/src/scoring.ts +78 -8
  48. package/src/security-flow-rules.ts +533 -0
  49. package/src/sensitive-data-rules.ts +138 -2
  50. package/src/test-block-rules.ts +140 -7
  51. package/src/test-fixtures.ts +59 -13
  52. package/src/types.ts +108 -5
package/CHANGELOG.md CHANGED
@@ -1,28 +1,64 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.1] - 2026-05-24
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
+
27
+ ## v0.2.0 - 2026-05-28
28
+
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.
30
+
31
+ - **Per-command gating + schemaVersion contract** - `analyse` and `summary` default `--fail-on` flips from `error` to `advisory`; CI gates using the defaults go from "fail on errors only" to "fail on anything." New `minimumSeverity:` block in `.gruff-ts.yaml` pins per-command thresholds (`analyse / summary / report`) with precedence CLI flag > config > binary default; `dashboard` is rejected as a key because it has no `--fail-on` flag. `.gruff-ts.yaml` now requires `schemaVersion: gruff-ts.config.v0.1` at the top - pre-1.0 hard break, no transitional shim. Run `npx gruff-ts init --force` to migrate; the regenerated config preserves `paths.ignore` and `minimumSeverity`. (ADR-004, `src/config.ts`, `src/cli-program.ts`)
32
+ - **Cross-format Pillars table** - Canonical 7-column table (`Pillar | Grade | Score | Findings | Advisory | Warning | Error`) renders byte-aligned across `text`, `json`, `html`, and `markdown`, sorted `findings DESC` then `pillar ASC`. Clean pillars render as `A/100` rows so the column layout stays stable run-to-run; cross-port consumers can diff byte-for-byte. (`src/pillar-summary.ts`, `src/report-renderers.ts`, `src/report-html.ts`)
33
+ - **JSON schema bumps `v1` → `v2`** - `summary --format=json` emits `gruff.summary.v2`; the flat `{pillar, count}` per-pillar array is replaced with a richer shape carrying `grade`, `score`, `penalty`, `applicable`, `findings`, `advisory`, `warning`, `error`. `analyse` / `report --format=json` emit `gruff.analysis.v2`; `score.pillars[]` entries gain a `penalty: number` field, and the SARIF `runs[0].properties.gruffSchemaVersion` plus the JSON `schemaVersion` tag move in lockstep. Downstream consumers must gate on the `schemaVersion` field before decoding.
34
+ - **Public-API doc gate** - `docs.missing-function-doc` (advisory) is split into `docs.missing-exported-function-doc` (**warning**) and `docs.missing-internal-function-doc` (advisory). The warning variant fires on `export function`, `export const f = () => ...`, `export default function`, and locally-declared functions re-exported via `export { foo }` or `export default foo`; `export { foo } from "./other"` re-export-from clauses are correctly skipped via negative lookahead so a same-named local stays internal. Class methods of exported classes are intentionally treated as internal (advisory) by this release; enclosing-class scope tracking is deferred. Any `.gruff-ts.yaml` override targeting the old rule ID must be updated. (M04, `src/blocks.ts`, `src/doc-rules.ts`)
35
+ - **Summary readability + rule explain mode** - Per-severity grade breakdown under the composite (`Errors: A (0)`, `Warnings: D (276)`, `Advisory: F (1367)`) tells you whether an F composite is driven by errors or by a long tail of advisories; three grade pills in HTML. `summary` Top-N rule rows now show per-severity split and one-line descriptions: `- <ruleId>: <total> (<err> err / <warn> warn / <adv> adv) - <description>`; a `Tip:` line points at `summary --top=20` when `analyse` produces 50+ findings. `gruff-ts list-rules <ruleId>` accepts a positional argument and prints per-rule detail (text or JSON) with `Config keys:`, `Options:`, and `Allowlists:` blocks. Every tunable rule's `remediation` text now names its override knob (`rules.<id>.threshold`, `rules.<id>.severity`, allowlist keys) so the configuration surface is one greppable string away from any finding. (M05-M08)
36
+ - **Rule-precision sweep** - `naming.short-variable` exempts single-character `for (const X of Y)` bindings whose body is ≤ 10 lines (and only those; classic `for (let i = 0; ...)` and `for (const k in obj)` stay covered). `test-quality.loop-in-test` recognises fixture loops (literal-array iterable or `Object.entries|keys|values(literal)`, no conditional bodies, last meaningful statement is an assertion) and suppresses the finding for them. `waste.swallowed-catch` accepts six additional rationale comments: `/* ignore */`, `/* ignored */`, `/* cleanup */`, `/* teardown */`, `/* noop */`, `/* no-op */`. `waste.unreachable-code` no longer fires on the unconditional return after a braceless `if`/`while`/`for` with a multi-line predicate. Nine imperative-flag verbs added to default `booleanPrefixes` (`check`, `skip`, `enable`, `allow`, `include`, `exclude`, `with`, `without`, `omit`); `fn` and `cb` added to default `acceptedAbbreviations`. (M01-M03)
37
+ - **Severity-only rule overrides accepted** - `rules.<id>.severity: warning` now loads without requiring `threshold`, fixing the validator that previously blocked any severity tweak on rules with no `threshold` knob (security, naming, docs, etc.) even though `gruff-ts list-rules` advertised the override. Each field is independently optional. (`src/config.ts:assertRuleThresholdConfig`)
38
+ - **Graceful CLI config errors** - Malformed `.gruff-ts.yaml`, missing `--config <path>`, and syntax errors in `.gruff.json` produce a formatted `gruff-ts: config error\n ...\nSuggested fix: ...` message and exit code 2; raw `ENOENT` / `SyntaxError` no longer leak through as Node stack traces. `init --force` over pre-schemaVersion configs preserves `paths.ignore` and `minimumSeverity` via a new permissive reader (`src/config-preservation.ts`), so existing curated entries survive the schemaVersion migration. (`src/cli-program.ts:runWithConfigErrorHandling`, `src/config.ts:parseConfigFile`, `src/init-config.ts`)
39
+ - **Release tooling** - `scripts/bump-version.sh --check` verifies `CHANGELOG.md`'s most-recent version heading agrees with `package.json` / `package-lock.json` / `src/constants.ts`; the preflight gate's `Version consistency` step uses it. The awk regex skips non-version headings (e.g. `## [Unreleased]`-style entries from third-party Keep-a-Changelog projects).
40
+ - **Regression coverage** - FP-#12 through FP-#45 added to `src/false-positive-fixes.test.ts`, covering every rule-precision change above plus negative regression guards. The PR #4 review sweep added FP-#33b through FP-#33e for re-export detection, the C-style for / for-in regression cases under `naming-rules.test.ts`, the pre-schemaVersion preservation regression in `src/init-config.test.ts`, and the dedicated `src/config-preservation.test.ts` suite. M06 / M08 land their tests in `src/rule-catalogue.test.ts` and `src/cli-surfaces.test.ts` respectively; M10-M12 add parser-rejection tests in `src/project-config-rules.test.ts`. M09 (informational tier) was deleted as a no-signal milestone.
41
+ - **Cross-port harmony** - `minimumSeverity:` dimension aligns with the gruff family (`gruff-go` / `gruff-rs` / `gruff-py` / `gruff-php` should track). Off-switch value is `none` (not `never`) per the noun-position re-evaluation; the verb-shaped `failOn: never` was the prior cross-port draft, the noun-shaped `minimumSeverity: none` is the family-wide decision.
42
+
43
+ ## v0.1.1 - 2026-05-24
4
44
 
5
45
  Onboarding flow, machine-readable summaries, and a `waste` → `maintainability` pillar rename. Catalogue is now 119 rules across 11 pillars.
6
46
 
7
- - **Breaking**: pillar `waste` renamed to `maintainability` — rule IDs unchanged, but text/JSON/SARIF parsers, dashboard nav, and the `Pillar` TypeScript union must update. Rules `docs.todo-density` and `naming.abbreviation` removed (both opt-in advisories), along with the now-unused `allowlists.abbreviationDenylist` config key; stale entries are silently ignored.
8
- - **Added**: `gruff-ts init` writes the default `.gruff-ts.yaml`, refusing to overwrite any supported config name without `--force` (which preserves existing `paths.ignore` entries). `analyse`, `summary`, `report`, and `dashboard` auto-prompt for `init` when no config is found, gated by `--no-interaction`, `--silent`/`--quiet`, and TTY checks so it never fires in CI.
9
- - **Added**: `summary --format=json` emits the new `gruff.summary.v1` schema; `summary --top <n>` controls digest size; a baseline status line surfaces source and suppression count. `dashboard --project-root <path>` sets the default scan root.
10
- - **Added**: docs index (`docs/README.md`) plus `ci-integration.md`, `dashboard.md`, `output-formats.md`, `rules.md`; CI now runs `npm audit --audit-level=moderate`.
11
- - **Fixed**: `summary`/`list-rules` `--format` rejects unsupported values via Commander instead of coercing to `text`; CLI switched to `parseAsync` so async handler rejections exit with the correct code.
12
- - **Fixed**: `summary --top <n>` now actually controls file-offender count beyond 10. `gruff.analysis.v1` `score.topOffenders` is now the full sorted file list (was capped at 10); HTML report and `--format=hotspot` still cap their own output at 10 rows. `init --force` help text now reflects that it also overrides the refusal triggered by non-canonical configs (`.gruff.yaml`/`.yml`/`.json`). `--top` added to the known-CLI-flag list so comments documenting it no longer trip `docs.stale-comment`.
13
- - **Changed**: docs filenames lowercased (`CONFIGURATION.md` → `configuration.md`, `RELEASING.md` → `releasing.md`, `REPORTS_AND_CI.md` → `reports-and-ci.md`).
47
+ - **Pillar rename `waste` → `maintainability`** - The pillar tag attached to every finding from a `waste.*` rule changed; rule IDs themselves keep their `waste.` prefix (so `waste.console-log` still fires as `waste.console-log`, only its pillar attribute moves). Text/JSON/SARIF parsers, dashboard nav, and the `Pillar` TypeScript union in `src/types.ts` must update.
48
+ - **Removed rules and config keys** - `docs.todo-density` and `naming.abbreviation` (both opt-in advisories) removed, along with the now-unused `allowlists.abbreviationDenylist` config key; stale config entries are silently ignored so existing `.gruff-ts.yaml` files keep loading. Consumers relying on either rule for CI gating lose that signal.
49
+ - **`gruff-ts init`** - Writes the default `.gruff-ts.yaml`, refusing to overwrite any supported config name without `--force` (which preserves existing `paths.ignore` entries). `analyse`, `summary`, `report`, and `dashboard` auto-prompt for `init` when no config is found, gated by `--no-interaction`, `--silent`/`--quiet`, and TTY checks so it never fires in CI.
50
+ - **Machine-readable summaries** - `summary --format=json` emits the new `gruff.summary.v1` schema; `summary --top <n>` controls digest size; a baseline status line surfaces source and suppression count. `dashboard --project-root <path>` sets the default scan root.
51
+ - **Docs index + audit gate** - New `docs/README.md` index plus `ci-integration.md`, `dashboard.md`, `output-formats.md`, `rules.md`; CI now runs `npm audit --audit-level=moderate`.
52
+ - **CLI input rejection + async exits** - `summary` and `list-rules` reject unsupported `--format` values via Commander instead of coercing to `text`; CLI switched to `parseAsync` so async handler rejections exit with the correct code.
53
+ - **Top-offender + flag-knowledge fixes** - `summary --top <n>` controls file-offender count beyond 10. `gruff.analysis.v1` `score.topOffenders` is now the full sorted file list (was capped at 10); HTML report and `--format=hotspot` still cap their own output at 10 rows. `init --force` help text now reflects that it also overrides the refusal triggered by non-canonical configs (`.gruff.yaml`/`.yml`/`.json`). `--top` added to the known-CLI-flag list so comments documenting it no longer trip `docs.stale-comment`.
54
+ - **Doc filename normalisation** - `CONFIGURATION.md` → `configuration.md`, `RELEASING.md` → `releasing.md`, `REPORTS_AND_CI.md` → `reports-and-ci.md`.
14
55
 
15
- ## [0.1.0] - 2026-05-23
56
+ ## v0.1.0 - 2026-05-23
16
57
 
17
58
  Initial public release of the `@blundergoat/gruff-ts` npm package.
18
59
 
19
- - TypeScript/JavaScript code quality scanner: 121 rules across 11 pillars
20
- (complexity, dead-code, design, documentation, maintainability,
21
- modernisation, naming, security, sensitive-data, size, test-quality).
22
- - CLI commands: `analyse`, `summary`, `report`, `list-rules`, `dashboard`,
23
- `completion`.
24
- - Output formats: `text`, `json`, `html`, `markdown`, `github`, `hotspot`,
25
- `sarif`. Stable schemas: `gruff.analysis.v1`, `gruff.baseline.v1`,
26
- `gruff.hotspot.v1`.
27
- - Baselines via stable per-finding fingerprints, `--diff` for changed-file
28
- scans, local dashboard on `127.0.0.1:8767`. Released under MIT.
60
+ - **TypeScript/JavaScript code-quality scanner** - 121 rules across 11 pillars: complexity, dead-code, design, documentation, maintainability, modernisation, naming, security, sensitive-data, size, test-quality.
61
+ - **CLI commands** - `analyse`, `summary`, `report`, `list-rules`, `dashboard`, `completion`.
62
+ - **Output formats** - `text`, `json`, `html`, `markdown`, `github`, `hotspot`, `sarif`. Stable schemas: `gruff.analysis.v1`, `gruff.baseline.v1`, `gruff.hotspot.v1`.
63
+ - **Baselines and diff scans** - Stable per-finding fingerprints; `--diff` for changed-file scans against the prior baseline. Local dashboard on `127.0.0.1:8767`.
64
+ - **License** - Released under MIT.
package/README.md CHANGED
@@ -1,23 +1,37 @@
1
1
  # gruff-ts
2
2
 
3
- `gruff-ts` is an opinionated static analyzer for TypeScript and JavaScript projects. The dependency-light Node.js CLI 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.
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.1.0` package line |
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 | 119 rules across 11 pillars |
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
- | Analysis schema | `gruff.analysis.v1` |
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, CSS, JSON, YAML, TOML, INI, XML, and `.env*`.
34
+ Scanned file types include TypeScript, JavaScript, JSON, YAML, TOML, INI, XML, and `.env*`.
21
35
 
22
36
  ## Requirements
23
37
 
@@ -31,8 +45,8 @@ Install as a project dev dependency:
31
45
 
32
46
  ```bash
33
47
  npm install --save-dev @blundergoat/gruff-ts
34
- ./node_modules/.bin/gruff-ts init
35
- ./node_modules/.bin/gruff-ts summary
48
+ npx gruff-ts init
49
+ npx gruff-ts summary
36
50
  ```
37
51
 
38
52
  From this checkout:
@@ -46,25 +60,25 @@ npm install
46
60
 
47
61
  ```bash
48
62
  # Create the project config.
49
- ./node_modules/.bin/gruff-ts init
63
+ npx gruff-ts init
50
64
 
51
65
  # Review the current finding mix.
52
- ./node_modules/.bin/gruff-ts summary
66
+ npx gruff-ts summary
53
67
 
54
68
  # Explore without failing because of findings.
55
- ./node_modules/.bin/gruff-ts analyse . --fail-on=none
69
+ npx gruff-ts analyse . --fail-on=none
56
70
 
57
71
  # Gate on warning and error findings.
58
- ./node_modules/.bin/gruff-ts analyse . --fail-on=warning
72
+ npx gruff-ts analyse . --fail-on=warning
59
73
 
60
74
  # Emit SARIF for code scanning.
61
- ./node_modules/.bin/gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
75
+ npx gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
62
76
 
63
77
  # Generate a fresh-start baseline.
64
- ./node_modules/.bin/gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
78
+ npx gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
65
79
 
66
80
  # Start the local dashboard.
67
- ./node_modules/.bin/gruff-ts dashboard
81
+ npx gruff-ts dashboard
68
82
  ```
69
83
 
70
84
  Open `http://127.0.0.1:8767/` for the dashboard.
@@ -73,11 +87,13 @@ Open `http://127.0.0.1:8767/` for the dashboard.
73
87
 
74
88
  | Command | Purpose |
75
89
  | --- | --- |
76
- | `analyse [paths...]` | Run the analyzer and print findings. |
90
+ | `analyse [paths...]` | Run the analyser and print findings. |
77
91
  | `summary [paths...]` | Print compact score, pillar, rule, and file summaries. |
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. |
@@ -91,7 +107,7 @@ Global console options match the broader gruff CLI surface: `--silent`, `--quiet
91
107
  | Format | Use it for |
92
108
  | --- | --- |
93
109
  | `text` | Human terminal output. |
94
- | `json` | Full `gruff.analysis.v1` report. |
110
+ | `json` | Full `gruff.analysis.v2` report. |
95
111
  | `html` | Self-contained inspection report. |
96
112
  | `markdown` | Pull-request or issue comment summary. |
97
113
  | `github` | GitHub Actions workflow annotations. |
@@ -108,26 +124,26 @@ Global console options match the broader gruff CLI surface: `--silent`, `--quiet
108
124
  | `1` | At least one finding met `--fail-on`. |
109
125
  | `2` | Fatal diagnostic such as missing input, parse error, config error, diff failure, baseline failure, or invalid input. |
110
126
 
111
- `analyse` defaults to `--fail-on error`.
127
+ `analyse` and `summary` default to `--fail-on advisory`; `report` defaults to `--fail-on none`. The defaults can be overridden per-project by a `minimumSeverity:` block in `.gruff-ts.yaml`. CLI flag wins over config; config wins over the binary default. See ADR-004 and the Configuration section.
112
128
 
113
129
  ## CI Usage
114
130
 
115
131
  Generic CI command:
116
132
 
117
133
  ```bash
118
- ./node_modules/.bin/gruff-ts analyse . --format=github --fail-on=warning
134
+ npx gruff-ts analyse . --format=github --fail-on=warning
119
135
  ```
120
136
 
121
137
  SARIF jobs can write an artifact for code scanning:
122
138
 
123
139
  ```bash
124
- ./node_modules/.bin/gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
140
+ npx gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
125
141
  ```
126
142
 
127
143
  Security-focused gates can bypass adoption baselines:
128
144
 
129
145
  ```bash
130
- ./node_modules/.bin/gruff-ts analyse . --no-baseline --fail-on=error
146
+ npx gruff-ts analyse . --no-baseline --fail-on=error
131
147
  ```
132
148
 
133
149
  ## Configuration
@@ -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,49 +182,98 @@ 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 v0.1 catalogue contains 119 rules:
226
+ The current catalogue contains 121 rules:
169
227
 
170
228
  | Pillar | Rules |
171
229
  | --- | ---: |
172
- | `complexity` | 3 |
230
+ | `complexity` | 2 |
173
231
  | `dead-code` | 1 |
174
- | `design` | 6 |
175
- | `documentation` | 17 |
232
+ | `design` | 5 |
233
+ | `documentation` | 18 |
176
234
  | `maintainability` | 14 |
177
235
  | `modernisation` | 14 |
178
236
  | `naming` | 10 |
179
- | `security` | 27 |
180
- | `sensitive-data` | 8 |
181
- | `size` | 4 |
237
+ | `security` | 29 |
238
+ | `sensitive-data` | 10 |
239
+ | `size` | 3 |
182
240
  | `test-quality` | 15 |
183
241
 
184
- Use `./node_modules/.bin/gruff-ts list-rules --format=json` for exact rule IDs, severities, confidence levels, remediation text, thresholds, and options.
242
+ Use `npx gruff-ts list-rules --format=json` for exact rule IDs, severities, confidence levels, remediation text, thresholds, and options.
185
243
 
186
244
  ## Baselines And Changed-Code Scans
187
245
 
188
246
  Baselines suppress reviewed findings by stable fingerprint:
189
247
 
190
248
  ```bash
191
- ./node_modules/.bin/gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
192
- ./node_modules/.bin/gruff-ts analyse . --baseline gruff-baseline.json --fail-on=warning
193
- ./node_modules/.bin/gruff-ts analyse . --no-baseline --fail-on=none
249
+ npx gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
250
+ npx gruff-ts analyse . --baseline gruff-baseline.json --fail-on=warning
251
+ npx gruff-ts analyse . --no-baseline --fail-on=none
194
252
  ```
195
253
 
196
254
  Changed-file scans use Git only when requested:
197
255
 
198
256
  ```bash
199
- ./node_modules/.bin/gruff-ts analyse . --diff=working-tree --format=github --fail-on=warning
200
- ./node_modules/.bin/gruff-ts analyse . --diff=staged --format=json --fail-on=none
257
+ npx gruff-ts analyse . --diff=working-tree --format=github --fail-on=warning
258
+ npx gruff-ts analyse . --diff=staged --format=json --fail-on=none
201
259
  ```
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
208
- ./node_modules/.bin/gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
276
+ npx gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
209
277
  ```
210
278
 
211
279
  The dashboard serves a local iframe report and compact controls panel. It has no authentication; keep the default loopback bind unless the network is trusted. The `/scan` endpoint analyses filesystem paths from request parameters, so the bind address is the main safety boundary.
@@ -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.1.x` line treats rule IDs, finding fingerprints, baseline identity, `gruff.analysis.v1`, `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).
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.
@@ -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:
@@ -25,9 +25,47 @@ Skip config for a run:
25
25
  gruff-ts analyse . --no-config
26
26
  ```
27
27
 
28
+ ## Required schema version
29
+
30
+ Every `.gruff-ts.yaml` must declare `schemaVersion: gruff-ts.config.v0.1` at the
31
+ top. Loading throws if the field is missing or carries a different value. The
32
+ field is in a different namespace from the output schemas (`gruff.analysis.v2`,
33
+ `gruff.summary.v2`, etc.) - the config-input version travels independently of
34
+ the output-payload versions. See ADR-004.
35
+
36
+ ## minimumSeverity (per-command gating defaults)
37
+
38
+ A top-level `minimumSeverity:` block sets the default `--fail-on` value per
39
+ command. The precedence chain is **CLI flag > config > binary default**.
40
+
41
+ ```yaml
42
+ schemaVersion: gruff-ts.config.v0.1
43
+ minimumSeverity:
44
+ analyse: advisory
45
+ summary: advisory
46
+ report: none
47
+ ```
48
+
49
+ Valid values: `advisory | warning | error | none`. The validator rejects any
50
+ other value (including `never`, which was an early cross-port draft for the
51
+ off-switch before the family converged on `none`).
52
+
53
+ `dashboard` is intentionally **not** a valid key in this block. The dashboard
54
+ subcommand has no `--fail-on` flag today; setting `minimumSeverity.dashboard:`
55
+ would be a silent no-op CI footgun, so the validator rejects it with a clear
56
+ error.
57
+
58
+ Binary defaults are `analyse: advisory`, `summary: advisory`, `report: none`.
59
+
28
60
  ## Shape
29
61
 
30
62
  ```yaml
63
+ schemaVersion: gruff-ts.config.v0.1
64
+ minimumSeverity:
65
+ analyse: advisory
66
+ summary: advisory
67
+ report: none
68
+
31
69
  paths:
32
70
  ignore:
33
71
  - "generated/**"
@@ -38,7 +76,8 @@ allowlists:
38
76
  - cli
39
77
  secretPreviews: []
40
78
  bannedGenericNames: [process, handle, doit, run, execute, manage]
41
- booleanPrefixes: [is, has, can, should, does, did, was, will, may, in, scan, supports, requires]
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]
42
81
  hungarianPrefixes: [str, obj, arr, bool, int, num]
43
82
  placeholderNames: [foo, bar, baz, tmp, temp, thing, stuff, data, value, item]
44
83
  negativeBooleanAllowed: [nostore, nofollow, noreferrer, noscript, noindex]
@@ -78,7 +117,21 @@ generated, node_modules, target, tmp, vendor
78
117
 
79
118
  Use `--include-ignored` when you intentionally want to scan default ignored
80
119
  directories and Git-ignored paths. Configured `paths.ignore` entries still
81
- 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
+ ```
82
135
 
83
136
  ## Allowlists
84
137
 
@@ -105,12 +158,13 @@ allowlists:
105
158
  Prefer fixing false positives with a narrow config entry instead of disabling an
106
159
  entire sensitive-data rule.
107
160
 
108
- Naming allowlists tune the 0.1.0 naming pack without changing rule ids or
161
+ Naming allowlists tune the 0.2.0 naming pack without changing rule ids or
109
162
  fingerprints:
110
163
 
111
164
  | Key | Used by | Default behavior |
112
165
  | --- | --- | --- |
113
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`. |
114
168
  | `bannedGenericNames` | `naming.generic-function` | Replaces the built-in generic function-name denylist. |
115
169
  | `booleanPrefixes` | `naming.boolean-prefix` | Replaces the accepted boolean-name prefixes such as `is`, `has`, `should`, `may`, `supports`, and `requires`. |
116
170
  | `hungarianPrefixes` | `naming.hungarian-notation` | Replaces type-style prefixes to flag. |
@@ -179,6 +233,9 @@ allowlists:
179
233
  - cli
180
234
  - env
181
235
  - id
236
+ acceptedBooleanNames:
237
+ - verbose
238
+ - enabled
182
239
  secretPreviews: []
183
240
 
184
241
  rules: